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

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

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

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

n = A("n")
i = B("i")
d = C("d")
l = D("l")
h = D("h")
c = D("c")
m = B("m")
e = B("e")

n.v = d
i.o = c
d.y = n
d.s = n
l.s = d
l.x = m
h.s = d
h.x = m
c.s = d
c.x = e
m.o = c
e.o = l
assert h.s.s.v.y.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
d = C("d")
l = D("l")
h = D("h")
c = D("c")
m = B("m")
e = B("e")

n.v = d
i.o = c
d.y = n
d.s = n
l.s = d
l.x = m
h.s = d
h.x = m
c.s = d
c.x = e
m.o = c
e.o = l
assert h.s.s.v.y.v.s.txt == "n"