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

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

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

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

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

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

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

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

m.t = j
m.z = j
m.w = g
j.u = m
j.s = m
j.z = g
g.z = m
g.x = m
g.q = e
e.z = m
e.x = m
e.q = g
assert j.z.x.t.z.txt == "g"