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

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

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

a = A("a")
j = B("j")
e = C("e")
g = C("g")

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

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

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

a = A("a")
j = B("j")
e = C("e")
g = C("g")

a.z = e
a.w = g
j.t = e
e.s = a
e.u = a
g.s = a
g.u = a
assert e.u.w.u.w.txt == "g"