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.v: A = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
c = C("c")
m = D("m")
i = C("i")
a = A("a")

n.y = m
n.s = i
e.v = n
c.w = i
c.t = e
c.p = a
m.p = a
i.w = c
i.t = e
i.p = a
a.y = m
a.s = c
assert m.p.s.p.y.p.s.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.v: A = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
c = C("c")
m = D("m")
i = C("i")
a = A("a")

n.y = m
n.s = i
e.v = n
c.w = i
c.t = e
c.p = a
m.p = a
i.w = c
i.t = e
i.p = a
a.y = m
a.s = c
assert m.p.s.p.y.p.s.txt == "c"