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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

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

n.w = g
e.y = n
e.v = n
e.t = g
m.q = n
m.y = g
m.z = g
g.y = n
g.v = n
g.t = e
assert e.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

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

n.w = g
e.y = n
e.v = n
e.t = g
m.q = n
m.y = g
m.z = g
g.y = n
g.v = n
g.t = e
assert e.t.t.t.t.txt == "e"