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

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

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

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

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

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

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