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

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

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

l = A("l")
f = B("f")
c = C("c")
k = B("k")
m = B("m")
n = A("n")
d = A("d")
a = C("a")
e = B("e")
h = A("h")

l.q = n
l.w = n
f.v = h
c.q = f
c.v = a
c.y = a
k.v = d
m.v = d
n.q = d
n.w = d
d.q = h
d.w = l
a.q = e
a.v = c
a.y = c
e.v = d
h.q = n
h.w = l
assert a.q.v.w.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: A = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
c = C("c")
k = B("k")
m = B("m")
n = A("n")
d = A("d")
a = C("a")
e = B("e")
h = A("h")

l.q = n
l.w = n
f.v = h
c.q = f
c.v = a
c.y = a
k.v = d
m.v = d
n.q = d
n.w = d
d.q = h
d.w = l
a.q = e
a.v = c
a.y = c
e.v = d
h.q = n
h.w = l
assert a.q.v.w.q.q.q.txt == "h"