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

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

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

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

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

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

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