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

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

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

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

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

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

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

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

m.s = g
f.t = e
f.u = e
f.z = e
e.x = m
e.u = f
g.s = m
assert f.t.u.u.u.txt == "f"