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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: C = None
        self.p: A = None
        self.u: E = None
        self.w: A = None
        self.txt = txt

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

h.w = k
b.q = a
d.q = b
e.x = g
e.w = n
n.r = d
n.y = d
n.p = l
n.u = a
n.w = g
k.r = d
k.y = d
k.p = h
k.w = h
k.u = n
a.r = d
a.y = d
a.p = l
a.u = k
a.w = h
g.w = k
l.w = a
assert e.w.u.p.w.u.r.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: C = None
        self.p: A = None
        self.u: E = None
        self.w: A = None
        self.txt = txt

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

h.w = k
b.q = a
d.q = b
e.x = g
e.w = n
n.r = d
n.y = d
n.p = l
n.u = a
n.w = g
k.r = d
k.y = d
k.p = h
k.w = h
k.u = n
a.r = d
a.y = d
a.p = l
a.u = k
a.w = h
g.w = k
l.w = a
assert e.w.u.p.w.u.r.q.q.txt == "a"