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

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

b = A("b")
k = B("k")
h = B("h")
a = A("a")
i = A("i")
j = A("j")
n = A("n")
m = B("m")
d = B("d")
c = A("c")

b.q = d
b.s = i
k.v = j
h.v = a
a.q = m
a.s = b
i.q = h
i.s = j
j.q = m
j.s = c
n.q = h
n.s = i
m.v = b
d.v = c
c.q = k
c.s = j
assert b.s.q.v.q.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: A = None
        self.txt = txt

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

b = A("b")
k = B("k")
h = B("h")
a = A("a")
i = A("i")
j = A("j")
n = A("n")
m = B("m")
d = B("d")
c = A("c")

b.q = d
b.s = i
k.v = j
h.v = a
a.q = m
a.s = b
i.q = h
i.s = j
j.q = m
j.s = c
n.q = h
n.s = i
m.v = b
d.v = c
c.q = k
c.s = j
assert b.s.q.v.q.v.q.v.txt == "c"