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

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

f = A("f")
l = B("l")
e = A("e")
b = B("b")
n = A("n")

f.s = b
f.t = n
l.o = b
e.s = b
e.t = n
b.o = l
n.s = b
n.t = e
assert e.t.t.s.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: A = None
        self.txt = txt

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

f = A("f")
l = B("l")
e = A("e")
b = B("b")
n = A("n")

f.s = b
f.t = n
l.o = b
e.s = b
e.t = n
b.o = l
n.s = b
n.t = e
assert e.t.t.s.o.o.txt == "b"