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

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

k = A("k")
b = B("b")
j = B("j")
l = A("l")
f = A("f")
m = B("m")
c = B("c")

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

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

k = A("k")
b = B("b")
j = B("j")
l = A("l")
f = A("f")
m = B("m")
c = B("c")

k.t = c
b.t = j
j.t = b
l.t = m
f.t = c
m.t = b
c.t = j
assert f.t.t.t.txt == "b"