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

b = A("b")
n = B("n")
k = B("k")
g = B("g")
l = A("l")
c = A("c")
f = A("f")
m = A("m")

b.z = l
n.t = l
k.t = f
g.t = m
l.z = f
c.z = m
f.z = l
m.z = l
assert k.t.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

b = A("b")
n = B("n")
k = B("k")
g = B("g")
l = A("l")
c = A("c")
f = A("f")
m = A("m")

b.z = l
n.t = l
k.t = f
g.t = m
l.z = f
c.z = m
f.z = l
m.z = l
assert k.t.z.z.txt == "f"