Ssari and Bird had nothing at all to do, so they built a pyramid of height N in the back yard and decided to write their favorite word on it. Row i from the top has i cells.
The word goes in one letter per cell, in a zigzag. Row 1 fills from left to right, row 2 from right to left, row 3 from left to right again, and so on. Once the word is written out, it starts over from its first letter.
For N=6 and the word JANJETINA the pyramid comes out like this.
J
N A
J E T
J A N I
A N J E T
N A J A N I
Bird picks a row number ai and an uppercase letter ci, then asks "how many times does ci appear in row ai?". Answer Bird's K questions and help Ssari out.
The first line contains the height of the pyramid, N (1≤N≤1018).
The second line contains a word made only of uppercase letters. The word is at most 106 letters long.
The third line contains the number of rows Bird picked, K (1≤K≤50000).
Each of the next K lines contains ai and ci separated by a space (1≤ai≤N, and ci is an uppercase letter).
Print K lines. Line i holds the number of times ci appears in row ai of the pyramid.