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

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

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

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

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

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

i.q = a
i.x = g
g.z = a
m.r = g
e.p = g
e.z = l
e.s = l
e.q = m
e.r = h
h.w = i
h.p = e
h.x = a
h.y = m
a.p = n
a.z = i
a.s = i
a.q = m
a.r = h
n.z = a
l.q = e
l.x = g
assert n.z.r.p.s.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

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

i.q = a
i.x = g
g.z = a
m.r = g
e.p = g
e.z = l
e.s = l
e.q = m
e.r = h
h.w = i
h.p = e
h.x = a
h.y = m
a.p = n
a.z = i
a.s = i
a.q = m
a.r = h
n.z = a
l.q = e
l.x = g
assert n.z.r.p.s.q.r.txt == "h"