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

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

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

d = A("d")
j = B("j")
f = C("f")
a = A("a")
c = C("c")
e = B("e")

d.z = e
j.p = c
j.w = d
j.u = e
f.u = j
f.t = c
a.z = j
c.u = j
c.t = f
e.p = c
e.w = d
e.u = j
assert d.z.u.w.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
f = C("f")
a = A("a")
c = C("c")
e = B("e")

d.z = e
j.p = c
j.w = d
j.u = e
f.u = j
f.t = c
a.z = j
c.u = j
c.t = f
e.p = c
e.w = d
e.u = j
assert d.z.u.w.z.p.txt == "c"