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

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

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

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

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

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

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