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

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

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

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

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

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

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

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

i.y = n
n.u = h
h.z = i
h.p = i
l.z = i
l.p = i
assert i.y.u.z.y.txt == "n"