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

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

m = A("m")
b = B("b")
f = B("f")
c = B("c")
e = A("e")
j = A("j")
l = A("l")
h = A("h")
d = B("d")
a = A("a")

m.t = f
m.z = a
b.z = c
f.z = c
c.z = d
e.t = c
e.z = l
j.t = b
j.z = a
l.t = f
l.z = a
h.t = c
h.z = j
d.z = b
a.t = f
a.z = h
assert f.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: A = None
        self.txt = txt

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

m = A("m")
b = B("b")
f = B("f")
c = B("c")
e = A("e")
j = A("j")
l = A("l")
h = A("h")
d = B("d")
a = A("a")

m.t = f
m.z = a
b.z = c
f.z = c
c.z = d
e.t = c
e.z = l
j.t = b
j.z = a
l.t = f
l.z = a
h.t = c
h.z = j
d.z = b
a.t = f
a.z = h
assert f.z.z.z.z.z.z.txt == "b"