class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: B = 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.s: A = None
        self.txt = txt

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

b.q = h
b.o = h
h.w = c
c.s = b
assert h.w.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: B = 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.s: A = None
        self.txt = txt

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

b.q = h
b.o = h
h.w = c
c.s = b
assert h.w.s.o.txt == "h"