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

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

l = A("l")
m = B("m")
i = A("i")
j = B("j")
f = A("f")
h = A("h")
a = A("a")
n = B("n")
b = A("b")

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

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

l = A("l")
m = B("m")
i = A("i")
j = B("j")
f = A("f")
h = A("h")
a = A("a")
n = B("n")
b = A("b")

l.t = f
m.u = b
i.t = f
j.u = a
f.t = a
h.t = f
a.t = f
n.u = h
b.t = i
assert h.t.t.t.t.t.t.txt == "a"