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

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

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

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

n.r = l
n.u = h
n.p = e
h.p = n
h.v = l
l.u = n
l.t = n
l.w = n
e.p = n
e.v = l
assert n.u.p.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: B = None
        self.p: B = None
        self.txt = txt

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

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

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

n.r = l
n.u = h
n.p = e
h.p = n
h.v = l
l.u = n
l.t = n
l.w = n
e.p = n
e.v = l
assert n.u.p.u.p.txt == "n"