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

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

c = A("c")
e = B("e")
j = A("j")
h = B("h")
i = A("i")
d = B("d")
m = A("m")
a = B("a")

c.r = d
c.t = j
e.u = a
j.r = a
j.t = i
h.u = e
i.r = e
i.t = j
d.u = e
m.r = d
m.t = j
a.u = e
assert a.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: A = None
        self.txt = txt

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

c = A("c")
e = B("e")
j = A("j")
h = B("h")
i = A("i")
d = B("d")
m = A("m")
a = B("a")

c.r = d
c.t = j
e.u = a
j.r = a
j.t = i
h.u = e
i.r = e
i.t = j
d.u = e
m.r = d
m.t = j
a.u = e
assert a.u.u.u.u.txt == "a"