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

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

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

b = A("b")
d = B("d")
a = C("a")
g = A("g")
j = B("j")

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

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

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

b = A("b")
d = B("d")
a = C("a")
g = A("g")
j = B("j")

b.z = d
b.t = j
b.u = a
d.w = j
d.z = b
d.u = g
a.p = j
a.z = d
g.z = d
g.t = j
g.u = a
j.w = d
j.z = g
j.u = g
assert a.p.z.z.txt == "d"