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

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

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

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

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

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

c.o = f
c.r = f
l.q = f
f.q = l
assert l.q.q.q.txt == "f"