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

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

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

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

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

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

l.q = a
l.x = d
k.v = j
k.r = h
d.v = k
d.r = a
j.v = k
j.r = l
b.v = d
b.r = h
m.q = l
m.x = g
g.v = d
g.r = a
e.v = g
e.r = m
a.q = h
a.x = d
h.q = l
h.x = k
assert k.r.x.r.x.r.x.v.r.q.q.txt == "h"