class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: C = None
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: C = None
        self.s: B = None
        self.txt = txt

c = A("c")
h = B("h")
m = C("m")
n = D("n")
l = B("l")
a = C("a")
b = C("b")

c.o = n
c.y = l
h.r = n
h.w = a
h.x = c
m.u = h
n.r = l
n.s = l
n.w = a
l.r = n
l.w = m
l.x = c
a.u = l
b.u = h
assert c.o.w.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: C = None
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: C = None
        self.s: B = None
        self.txt = txt

c = A("c")
h = B("h")
m = C("m")
n = D("n")
l = B("l")
a = C("a")
b = C("b")

c.o = n
c.y = l
h.r = n
h.w = a
h.x = c
m.u = h
n.r = l
n.s = l
n.w = a
l.r = n
l.w = m
l.x = c
a.u = l
b.u = h
assert c.o.w.u.x.txt == "c"