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

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

l = A("l")
e = B("e")
f = B("f")
b = A("b")
m = B("m")
a = A("a")
j = B("j")

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

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

l = A("l")
e = B("e")
f = B("f")
b = A("b")
m = B("m")
a = A("a")
j = B("j")

l.u = e
e.t = m
f.t = m
b.u = e
m.t = e
a.u = f
j.t = e
assert f.t.t.t.t.t.t.txt == "e"