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

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

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

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

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

n.u = l
h.p = n
l.y = h
l.s = h
l.p = n
a.y = l
e.u = l
assert a.y.p.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

n.u = l
h.p = n
l.y = h
l.s = h
l.p = n
a.y = l
e.u = l
assert a.y.p.u.s.txt == "h"