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

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

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

l = A("l")
f = B("f")
i = C("i")

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

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

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

l = A("l")
f = B("f")
i = C("i")

l.r = i
f.o = i
f.q = i
i.q = f
i.s = f
assert l.r.s.q.txt == "i"