## ICHB Selection Contest '17 Problem 2 - Black Star's Visit

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Black Star hates people that are not symmetrical. He defines symmetry for numbers either horizontal symmetry (each digit, when cut in half horizontally, must have the same upper half as lower half), or vertical symmetry (when cutting the number at the middle digit/digits, the -th digit from the half towards the start must be equal to the -th digit from the half towards the end). Each city in his country is indexed from to , and for a city its citizens are numbered from to (all the natural numbers of digits). Furthermore, we know that Black Star will visit cities out of the , and for each of them he wants to know how many people in that city he hates. However, since the number is pretty large, he asks us the number . Since we also have other tasks at hand given by Black Star, we ask you to give us the answer for the cities.

#### Input Specification

On the first line, there will be two space separated integers and .
On the second line there will be the cities Black Star asks about.

#### Output Specification

There will be numbers, each number on a separate line.
The number on the -th line will be the answer to the -th city from the input.

#### Sample Input

3 2
1 2

#### Sample Output

0
77