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

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

a = A("a")
c = B("c")
l = B("l")
g = A("g")
m = A("m")
i = A("i")
b = A("b")
f = A("f")

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

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

a = A("a")
c = B("c")
l = B("l")
g = A("g")
m = A("m")
i = A("i")
b = A("b")
f = A("f")

a.z = g
c.t = m
l.t = f
g.z = f
m.z = a
i.z = m
b.z = a
f.z = i
assert g.z.z.z.z.txt == "a"