Black Star hates people that are not symmetrical. He defines symmetry for numbers as 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 digit from the half towards the start must be equal to the 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.
Constraints
Subtask 1 [50%]
Subtask 2 [50%]
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 line will be the answer to the city from the input.
Sample Input
3 2
1 2
Sample Output
0
77
Comments