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

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

k = A("k")
d = B("d")
b = B("b")
a = A("a")
j = B("j")
n = B("n")
e = B("e")
f = B("f")

k.z = a
d.t = b
b.t = n
a.z = k
j.t = e
n.t = j
e.t = b
f.t = j
assert j.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

k = A("k")
d = B("d")
b = B("b")
a = A("a")
j = B("j")
n = B("n")
e = B("e")
f = B("f")

k.z = a
d.t = b
b.t = n
a.z = k
j.t = e
n.t = j
e.t = b
f.t = j
assert j.t.t.t.t.t.txt == "e"