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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: C = None
        self.w: D = None
        self.u: B = None
        self.txt = txt

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

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

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

m.z = l
a.q = k
a.t = b
a.w = d
a.u = c
b.x = i
b.q = m
l.s = m
l.q = c
l.o = a
l.p = d
d.s = m
d.q = n
d.o = c
d.p = l
g.s = m
g.q = c
g.o = i
g.p = d
k.x = i
k.q = m
c.q = k
c.t = b
c.w = d
c.u = n
i.q = b
i.t = k
i.w = d
i.u = n
n.q = k
n.t = k
n.w = g
n.u = i
assert d.s.z.s.z.q.t.q.z.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: C = None
        self.w: D = None
        self.u: B = None
        self.txt = txt

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

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

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

m.z = l
a.q = k
a.t = b
a.w = d
a.u = c
b.x = i
b.q = m
l.s = m
l.q = c
l.o = a
l.p = d
d.s = m
d.q = n
d.o = c
d.p = l
g.s = m
g.q = c
g.o = i
g.p = d
k.x = i
k.q = m
c.q = k
c.t = b
c.w = d
c.u = n
i.q = b
i.t = k
i.w = d
i.u = n
n.q = k
n.t = k
n.w = g
n.u = i
assert d.s.z.s.z.q.t.q.z.p.o.txt == "c"