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

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

b = A("b")
c = B("c")
f = B("f")
l = B("l")
e = B("e")
k = A("k")
i = A("i")
g = B("g")

b.t = l
c.o = i
f.o = b
l.o = b
e.o = i
k.t = l
i.t = g
g.o = k
assert e.o.t.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
f = B("f")
l = B("l")
e = B("e")
k = A("k")
i = A("i")
g = B("g")

b.t = l
c.o = i
f.o = b
l.o = b
e.o = i
k.t = l
i.t = g
g.o = k
assert e.o.t.o.t.o.txt == "b"