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

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

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

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

k = A("k")
a = B("a")
e = C("e")
j = D("j")
f = C("f")
g = D("g")
b = D("b")
m = B("m")
i = B("i")

k.z = e
a.u = k
e.z = k
e.p = b
e.y = f
j.p = i
j.x = k
j.r = a
f.z = k
f.p = j
f.y = e
g.p = a
g.r = a
g.x = k
b.p = a
b.r = a
b.x = k
m.u = k
i.u = k
assert k.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

k = A("k")
a = B("a")
e = C("e")
j = D("j")
f = C("f")
g = D("g")
b = D("b")
m = B("m")
i = B("i")

k.z = e
a.u = k
e.z = k
e.p = b
e.y = f
j.p = i
j.x = k
j.r = a
f.z = k
f.p = j
f.y = e
g.p = a
g.r = a
g.x = k
b.p = a
b.r = a
b.x = k
m.u = k
i.u = k
assert k.z.z.z.txt == "e"