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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: C = None
        self.txt = txt

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

l = A("l")
j = B("j")
g = C("g")

l.r = g
l.s = g
l.q = g
j.p = l
j.w = g
g.o = l
assert l.r.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: C = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: C = None
        self.txt = txt

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

l = A("l")
j = B("j")
g = C("g")

l.r = g
l.s = g
l.q = g
j.p = l
j.w = g
g.o = l
assert l.r.o.s.txt == "g"