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

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

l = A("l")
k = B("k")
c = B("c")
f = B("f")

l.o = k
k.x = c
k.s = l
c.x = f
c.s = l
f.x = k
f.s = l
assert f.s.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

l = A("l")
k = B("k")
c = B("c")
f = B("f")

l.o = k
k.x = c
k.s = l
c.x = f
c.s = l
f.x = k
f.s = l
assert f.s.o.s.o.txt == "k"