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

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: E = None
        self.v: A = None
        self.r: B = None
        self.q: C = None
        self.txt = txt

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

m.w = i
b.p = a
n.u = e
n.w = e
n.s = g
n.q = l
j.s = i
a.w = i
a.v = m
a.r = g
a.q = n
i.w = a
i.v = m
i.r = b
i.q = l
l.u = e
l.s = g
l.q = n
l.w = j
e.s = i
g.p = i
assert l.u.s.q.w.s.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: E = None
        self.v: A = None
        self.r: B = None
        self.q: C = None
        self.txt = txt

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

m.w = i
b.p = a
n.u = e
n.w = e
n.s = g
n.q = l
j.s = i
a.w = i
a.v = m
a.r = g
a.q = n
i.w = a
i.v = m
i.r = b
i.q = l
l.u = e
l.s = g
l.q = n
l.w = j
e.s = i
g.p = i
assert l.u.s.q.w.s.r.p.txt == "a"