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

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

b = A("b")
e = B("e")
l = A("l")
i = A("i")
k = B("k")
h = A("h")
f = B("f")

b.z = k
e.t = h
l.z = e
i.z = f
k.t = h
h.z = e
f.t = i
assert e.t.z.t.z.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

b = A("b")
e = B("e")
l = A("l")
i = A("i")
k = B("k")
h = A("h")
f = B("f")

b.z = k
e.t = h
l.z = e
i.z = f
k.t = h
h.z = e
f.t = i
assert e.t.z.t.z.t.z.t.txt == "h"