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

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

d = A("d")
m = B("m")
i = B("i")
l = A("l")
k = B("k")
f = B("f")
e = B("e")
j = B("j")
g = B("g")

d.t = l
m.q = j
m.z = d
i.q = e
i.z = d
l.t = d
k.q = e
k.z = l
f.q = e
f.z = l
e.q = g
e.z = d
j.q = m
j.z = d
g.q = j
g.z = d
assert l.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

d = A("d")
m = B("m")
i = B("i")
l = A("l")
k = B("k")
f = B("f")
e = B("e")
j = B("j")
g = B("g")

d.t = l
m.q = j
m.z = d
i.q = e
i.z = d
l.t = d
k.q = e
k.z = l
f.q = e
f.z = l
e.q = g
e.z = d
j.q = m
j.z = d
g.q = j
g.z = d
assert l.t.t.t.t.t.t.txt == "l"