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

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

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

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

n = A("n")
g = B("g")
h = C("h")
e = D("e")
l = D("l")
k = B("k")
d = A("d")
j = A("j")
c = A("c")

n.y = l
n.s = h
g.p = n
g.y = n
g.r = n
g.s = k
h.v = e
h.z = d
e.p = k
l.p = g
k.p = n
k.r = n
k.s = g
k.y = c
d.y = e
d.s = h
j.y = e
j.s = h
c.y = e
c.s = h
assert n.y.p.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: C = None
        self.txt = txt

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

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

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

n = A("n")
g = B("g")
h = C("h")
e = D("e")
l = D("l")
k = B("k")
d = A("d")
j = A("j")
c = A("c")

n.y = l
n.s = h
g.p = n
g.y = n
g.r = n
g.s = k
h.v = e
h.z = d
e.p = k
l.p = g
k.p = n
k.r = n
k.s = g
k.y = c
d.y = e
d.s = h
j.y = e
j.s = h
c.y = e
c.s = h
assert n.y.p.s.r.txt == "n"