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

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

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

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

h = A("h")
k = B("k")
j = C("j")
a = D("a")
n = A("n")
m = D("m")
d = C("d")
e = B("e")
i = B("i")
g = B("g")

h.s = i
h.z = a
h.x = m
h.y = n
k.s = a
k.o = n
k.p = m
k.y = m
j.v = h
a.p = n
n.s = g
n.z = a
n.x = m
n.y = h
m.p = n
d.v = h
e.s = a
e.o = h
e.p = m
e.y = m
i.s = a
i.o = n
i.p = m
i.y = m
g.s = a
g.y = a
g.o = h
g.p = m
assert d.v.s.o.y.z.p.s.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: D = None
        self.x: D = None
        self.y: A = None
        self.txt = txt

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

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

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

h = A("h")
k = B("k")
j = C("j")
a = D("a")
n = A("n")
m = D("m")
d = C("d")
e = B("e")
i = B("i")
g = B("g")

h.s = i
h.z = a
h.x = m
h.y = n
k.s = a
k.o = n
k.p = m
k.y = m
j.v = h
a.p = n
n.s = g
n.z = a
n.x = m
n.y = h
m.p = n
d.v = h
e.s = a
e.o = h
e.p = m
e.y = m
i.s = a
i.o = n
i.p = m
i.y = m
g.s = a
g.y = a
g.o = h
g.p = m
assert d.v.s.o.y.z.p.s.o.z.txt == "a"