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

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

e = A("e")
f = B("f")
h = A("h")
a = A("a")
i = B("i")
m = B("m")
l = B("l")

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

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

e = A("e")
f = B("f")
h = A("h")
a = A("a")
i = B("i")
m = B("m")
l = B("l")

e.x = l
e.u = f
f.r = l
f.t = i
h.x = i
h.u = f
a.x = m
a.u = m
i.r = f
i.t = l
m.r = i
m.t = l
l.r = m
l.t = i
assert i.t.t.t.r.t.r.txt == "m"