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

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

n = A("n")
d = B("d")
e = B("e")
k = B("k")
a = A("a")
i = B("i")
b = A("b")
m = A("m")
f = B("f")

n.v = a
n.q = a
d.o = b
e.o = a
k.o = m
a.v = m
a.q = m
i.o = m
b.v = n
b.q = a
m.v = b
m.q = b
f.o = a
assert k.o.v.q.q.q.v.v.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: A = None
        self.txt = txt

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

n = A("n")
d = B("d")
e = B("e")
k = B("k")
a = A("a")
i = B("i")
b = A("b")
m = A("m")
f = B("f")

n.v = a
n.q = a
d.o = b
e.o = a
k.o = m
a.v = m
a.q = m
i.o = m
b.v = n
b.q = a
m.v = b
m.q = b
f.o = a
assert k.o.v.q.q.q.v.v.q.q.txt == "b"