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

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

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

m = A("m")
h = B("h")
a = C("a")

m.o = a
m.x = a
m.u = h
h.q = a
a.p = m
a.u = h
assert m.x.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: C = None
        self.u: B = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
a = C("a")

m.o = a
m.x = a
m.u = h
h.q = a
a.p = m
a.u = h
assert m.x.u.q.txt == "a"