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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: A = None
        self.v: C = None
        self.t: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

k = A("k")
m = B("m")
l = C("l")
h = D("h")
j = B("j")
a = C("a")
i = D("i")
n = D("n")

k.q = l
k.o = m
m.x = k
m.r = k
m.v = l
m.t = h
l.s = h
h.v = a
h.o = m
j.x = k
j.r = k
j.v = a
j.t = i
a.s = h
i.v = l
i.o = m
n.v = a
n.o = m
assert j.t.v.s.o.v.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: A = None
        self.v: C = None
        self.t: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

k = A("k")
m = B("m")
l = C("l")
h = D("h")
j = B("j")
a = C("a")
i = D("i")
n = D("n")

k.q = l
k.o = m
m.x = k
m.r = k
m.v = l
m.t = h
l.s = h
h.v = a
h.o = m
j.x = k
j.r = k
j.v = a
j.t = i
a.s = h
i.v = l
i.o = m
n.v = a
n.o = m
assert j.t.v.s.o.v.s.v.s.txt == "h"