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

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

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

l = A("l")
f = B("f")
n = C("n")
i = B("i")

l.z = n
l.u = n
f.x = l
n.p = l
n.z = l
i.x = l
assert n.p.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: C = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
n = C("n")
i = B("i")

l.z = n
l.u = n
f.x = l
n.p = l
n.z = l
i.x = l
assert n.p.u.z.u.txt == "n"