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

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

d = A("d")
j = B("j")
b = A("b")
a = B("a")
k = B("k")
l = A("l")
e = B("e")
i = B("i")

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

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

d = A("d")
j = B("j")
b = A("b")
a = B("a")
k = B("k")
l = A("l")
e = B("e")
i = B("i")

d.t = j
j.z = e
j.u = b
b.t = e
a.z = j
a.u = d
k.z = i
k.u = d
l.t = e
e.z = k
e.u = l
i.z = e
i.u = b
assert k.u.t.z.z.u.t.u.txt == "b"