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

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.p: D = None
        self.t: D = None
        self.txt = txt

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

i.q = c
e.t = g
d.s = l
d.v = k
d.r = k
d.p = g
m.o = d
m.s = l
m.p = c
m.t = n
l.s = d
l.v = k
l.r = i
l.p = g
c.o = l
c.s = l
c.p = n
c.t = n
n.o = d
n.s = d
n.p = c
n.t = c
a.q = n
g.t = e
k.q = m
assert n.s.r.q.t.p.s.s.p.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.p: D = None
        self.t: D = None
        self.txt = txt

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

i.q = c
e.t = g
d.s = l
d.v = k
d.r = k
d.p = g
m.o = d
m.s = l
m.p = c
m.t = n
l.s = d
l.v = k
l.r = i
l.p = g
c.o = l
c.s = l
c.p = n
c.t = n
n.o = d
n.s = d
n.p = c
n.t = c
a.q = n
g.t = e
k.q = m
assert n.s.r.q.t.p.s.s.p.t.t.txt == "g"