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

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

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

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

b = A("b")
d = B("d")
m = C("m")
h = D("h")
j = C("j")
e = A("e")
c = D("c")
k = A("k")

b.x = h
b.u = d
b.z = m
d.w = b
m.r = d
h.w = d
h.s = j
h.r = j
j.r = d
e.x = h
e.u = d
e.z = m
c.w = d
c.s = m
c.r = m
k.x = h
k.u = d
k.z = m
assert c.w.w.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: B = None
        self.z: C = None
        self.txt = txt

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

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

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

b = A("b")
d = B("d")
m = C("m")
h = D("h")
j = C("j")
e = A("e")
c = D("c")
k = A("k")

b.x = h
b.u = d
b.z = m
d.w = b
m.r = d
h.w = d
h.s = j
h.r = j
j.r = d
e.x = h
e.u = d
e.z = m
c.w = d
c.s = m
c.r = m
k.x = h
k.u = d
k.z = m
assert c.w.w.z.r.txt == "d"