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

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

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

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

j.z = h
j.p = c
j.o = i
c.u = j
h.r = j
i.u = j
assert j.o.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: B = None
        self.o: B = None
        self.txt = txt

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

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

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

j.z = h
j.p = c
j.o = i
c.u = j
h.r = j
i.u = j
assert j.o.u.p.txt == "c"