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

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

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

j = A("j")
m = B("m")
f = C("f")
g = A("g")
h = A("h")
k = C("k")
l = C("l")
n = A("n")
d = C("d")
a = B("a")

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

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

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

j = A("j")
m = B("m")
f = C("f")
g = A("g")
h = A("h")
k = C("k")
l = C("l")
n = A("n")
d = C("d")
a = B("a")

j.o = m
m.w = f
f.q = k
f.v = m
g.o = a
h.o = m
k.q = l
k.v = m
l.q = f
l.v = a
n.o = a
d.q = k
d.v = m
a.w = l
assert l.v.w.q.q.v.w.v.w.q.q.txt == "l"