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

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

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

h = A("h")
i = B("i")
a = C("a")
c = B("c")

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

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

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

h = A("h")
i = B("i")
a = C("a")
c = B("c")

h.o = c
h.x = c
i.u = h
i.p = a
i.o = a
a.p = h
c.u = h
c.p = a
c.o = a
assert i.o.p.x.txt == "c"