
Suhana and Equation
|
All submissions for this problem are available.
Suhana is studying following equation :
f(N) = 00 + 11 + 22 + 33 + 44 + ... + NN
Can you solve f(N) % M before Suhana does?
Input
First line contains T, number of test cases.
First line of each test case contains N and M.
Output
Output the required answer in new line.
Constraints
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 10^9
- 1 ≤ M ≤ 10^3
Example
Input: 4 1 9 2 29 3 93 40 993 Output: 2 6 33 907
Author: | codopediac3 |
Tags | codopediac3 |
Date Added: | 15-07-2017 |
Time Limit: | 1 sec |
Source Limit: | 50000 Bytes |
Languages: | C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS |
Comments
- Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
