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

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

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

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

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

h.r = j
i.z = n
i.r = g
k.q = l
k.w = l
k.s = j
k.r = g
j.q = l
a.q = g
a.r = g
a.s = j
a.w = k
n.z = d
n.r = k
g.q = k
g.w = k
g.s = j
g.r = a
e.z = d
e.r = a
l.q = a
l.r = a
l.s = j
l.w = k
d.z = i
d.r = k
assert l.s.q.s.q.w.r.s.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

h.r = j
i.z = n
i.r = g
k.q = l
k.w = l
k.s = j
k.r = g
j.q = l
a.q = g
a.r = g
a.s = j
a.w = k
n.z = d
n.r = k
g.q = k
g.w = k
g.s = j
g.r = a
e.z = d
e.r = a
l.q = a
l.r = a
l.s = j
l.w = k
d.z = i
d.r = k
assert l.s.q.s.q.w.r.s.q.q.q.txt == "g"