class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

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

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

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

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

i.o = d
g.r = a
g.q = k
g.w = l
n.q = d
e.q = g
k.q = d
m.o = d
l.o = g
d.r = h
d.q = n
d.w = m
a.q = d
h.q = g
assert a.q.q.q.q.q.w.o.r.txt == "h"