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

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

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

a = A("a")
i = B("i")
n = C("n")

a.u = i
i.s = a
i.z = a
n.z = i
n.y = i
n.p = i
assert a.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
n = C("n")

a.u = i
i.s = a
i.z = a
n.z = i
n.y = i
n.p = i
assert a.u.z.u.txt == "i"