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

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

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

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

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

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

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

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

h.q = e
h.v = c
k.w = g
k.u = b
l.r = g
l.q = k
a.w = g
a.u = j
j.w = h
j.u = b
g.q = c
g.v = m
e.r = h
e.q = j
c.r = h
c.q = k
m.r = h
m.q = j
b.w = h
b.u = k
assert c.q.w.q.q.w.q.q.u.w.txt == "h"