We call the number of different digitals at the same position of two phone numbers: 'difference'.
Number 1: 1 3 6 0 0 0 0 0 0 0 0
Number 2: 1 4 6 0 0 0 0 0 0 0 1
Difference: 0+1+0+0+0+0+0+0+0+0+1 = 2
Search the booklet and find out the numbers between the difference A and B to the given correct phone numbers.
輸入
The first line of the input is two integers: n and m. n is the numbers counted on the booklet, while m is the given correct phone numbers (0 < n ≤ 1000, 0 < m ≤ 200).
Then follow n lines. On each line is a phone number in the booklet which are all distinct. Then m lines, on each line there is a correct given phone number and difference A and B (0 ≤ A, B ≤ 11). Note: all the input phone numbers will be valid phone number: 11 digitals per number.
輸出
For each given correct phone number, print "Number *:"(* should be replaced by the order this number shows up).
Then print all the within-difference number in the booklet. Ordered as the same as in the booklet.
Then follows a line printed "Total: *", * should be replaced by the total number of the within-difference numbers.
Then print a blank line after each given correct phone number.
樣例輸入
4 2
13600000000
13500000001
13700000001
15500000000
13600000000 1 1
13700000001 1 2
樣例輸出
Number 1:
Total: 0
Number 2:
13600000000
13500000001
Total: 2
參考代碼