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

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: E = None
        self.s: C = None
        self.q: B = None
        self.p: C = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: D = None
        self.txt = txt

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

l.s = g
i.s = d
d.z = g
d.q = g
d.r = m
d.s = a
d.p = a
k.q = a
m.p = a
m.r = k
a.z = i
a.q = i
a.r = m
a.s = d
a.p = d
g.s = a
n.p = a
n.r = k
b.s = i
assert l.s.s.s.r.r.q.r.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: E = None
        self.s: C = None
        self.q: B = None
        self.p: C = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: D = None
        self.txt = txt

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

l.s = g
i.s = d
d.z = g
d.q = g
d.r = m
d.s = a
d.p = a
k.q = a
m.p = a
m.r = k
a.z = i
a.q = i
a.r = m
a.s = d
a.p = d
g.s = a
n.p = a
n.r = k
b.s = i
assert l.s.s.s.r.r.q.r.p.q.txt == "i"