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

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

b = A("b")
f = B("f")
k = B("k")

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

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

b = A("b")
f = B("f")
k = B("k")

b.o = f
b.q = k
f.s = k
k.s = f
assert k.s.s.s.txt == "f"