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

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

l = A("l")
b = B("b")
m = A("m")
c = B("c")
g = A("g")

l.t = c
l.v = b
b.z = c
m.t = c
m.v = c
c.z = b
g.t = b
g.v = b
assert c.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

l = A("l")
b = B("b")
m = A("m")
c = B("c")
g = A("g")

l.t = c
l.v = b
b.z = c
m.t = c
m.v = c
c.z = b
g.t = b
g.v = b
assert c.z.z.z.z.txt == "c"