Test generation

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

A while ago Pasha came up with a simple problem for a programming contest training session. The input data in the problem consists of the line SS containing NN digits, and three integers LL, RR and PP (1LRN1 \leq L \leq R \leq N, PP being a prime number). The requested output was the remainder from the division of the subnumber formed by digits at the positions from LL through RR, inclusively, by the number PP. It should be noted that this subnumber may contain leading zeroes. Pasha prepared the problem description, wrote a solution and prepared lots of tests to check the solutions.

Before a practice session, Pasha discovered that TT files with input test data were gone, and only the corresponding answer files remained. He remembers that the line SS in all these tests was identical, moreover, he remembers that line perfectly well. Similarly, he remembers the value of PP, which was also identical in all missing tests. To recover the lost input data, Pasha is asking for your help. Write a program which is given a line SS of the length NN, the numbers PP and TT, as well as TT values of A_iA\_{i} --- the answers for the lost test data. For each A_iA\_{i}, the program must figure out the number of different pairs {L_iL\_{i}, R_iR\_{i}} (1L_iR_iN1 \leq L\_{i} \leq R\_{i} \leq N) --- the pairs of acceptable values from the input file, as well as find one of these pairs.

입력

The first line of the input file contains the line SS, consisting of NN decimal digits (1N1051 \leq N \leq 10^{5}). The second line of the input data contains two integers TT and PP --- the number of the lost tests and the prime number, for which the remainder from the division by that number was to be calculated.(1T1001 \leq T \leq 100, 11P109+3311 \leq P \leq 10^{9} + 33, PP --- the prime number). This is followed by TT lines, with the ii-th line containing a single integer A_iA\_{i} --- the answer for the ii-th test input dataset (0R_i<P0 \leq R\_{i} < P).

출력

For each of these TT solutions, the output file must receive three integers C_iC\_{i}, L_iL\_{i} and R_iR\_{i} --- the number of different acceptable pairs of input values, and the values of one of those pairs, respectively. If Pasha has made an error when preparing the tests, and there are no acceptable pairs for a solution, three zeroes must be printed.