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

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

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

f = A("f")
h = B("h")
g = C("g")

f.o = g
f.p = g
h.s = g
g.q = f
g.u = h
assert g.u.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: C = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
g = C("g")

f.o = g
f.p = g
h.s = g
g.q = f
g.u = h
assert g.u.s.q.txt == "f"