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

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

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

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

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

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

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

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

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

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

h.y = d
h.o = d
h.z = c
i.p = d
i.z = j
i.v = n
i.y = c
j.x = l
j.w = d
n.x = m
c.p = d
c.z = m
c.v = k
c.y = i
l.x = m
l.w = d
k.x = m
e.x = m
m.x = j
m.w = d
d.y = h
d.o = h
d.z = i
assert k.x.w.z.z.w.o.o.z.v.txt == "n"