class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: A = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
c = C("c")
e = A("e")
l = C("l")
b = C("b")
j = A("j")
a = C("a")
i = C("i")
m = B("m")

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

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

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

h = A("h")
g = B("g")
c = C("c")
e = A("e")
l = C("l")
b = C("b")
j = A("j")
a = C("a")
i = C("i")
m = B("m")

h.z = e
h.q = e
g.s = j
g.r = l
g.w = e
c.w = h
c.r = i
e.z = h
e.q = j
l.w = j
l.r = b
b.w = e
b.r = a
j.z = h
j.q = h
a.w = e
a.r = i
i.w = j
i.r = a
m.s = e
m.w = e
m.r = i
assert l.r.r.w.q.z.q.q.z.z.txt == "e"