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

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

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

g = A("g")
c = B("c")
b = C("b")

g.q = c
g.p = b
c.w = b
b.o = c
assert b.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: C = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
b = C("b")

g.q = c
g.p = b
c.w = b
b.o = c
assert b.o.w.o.txt == "c"