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

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

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

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

n = A("n")
l = B("l")
c = C("c")
a = D("a")
i = D("i")
g = D("g")
d = A("d")

n.x = c
n.y = l
n.s = a
l.p = i
c.z = g
a.s = l
a.y = l
a.v = c
a.x = g
i.s = l
i.y = l
i.v = c
i.x = g
g.s = l
g.y = l
g.v = c
g.x = i
d.x = c
d.y = l
d.s = a
assert d.y.p.x.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: B = None
        self.s: D = None
        self.txt = txt

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

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

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

n = A("n")
l = B("l")
c = C("c")
a = D("a")
i = D("i")
g = D("g")
d = A("d")

n.x = c
n.y = l
n.s = a
l.p = i
c.z = g
a.s = l
a.y = l
a.v = c
a.x = g
i.s = l
i.y = l
i.v = c
i.x = g
g.s = l
g.y = l
g.v = c
g.x = i
d.x = c
d.y = l
d.s = a
assert d.y.p.x.v.z.txt == "g"