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

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

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

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

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

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

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

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

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