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

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

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

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

b = A("b")
m = B("m")
k = C("k")
l = D("l")
h = B("h")
d = C("d")
n = A("n")

b.z = k
b.r = d
b.x = m
m.y = k
k.z = d
k.u = d
k.y = b
l.w = h
l.s = b
l.q = d
l.p = n
h.y = d
d.z = k
d.u = k
d.y = n
n.z = d
n.r = d
n.x = h
assert n.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: C = None
        self.x: B = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
k = C("k")
l = D("l")
h = B("h")
d = C("d")
n = A("n")

b.z = k
b.r = d
b.x = m
m.y = k
k.z = d
k.u = d
k.y = b
l.w = h
l.s = b
l.q = d
l.p = n
h.y = d
d.z = k
d.u = k
d.y = n
n.z = d
n.r = d
n.x = h
assert n.z.u.z.txt == "d"