2349: Remainder Calculator

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:36 解决:9

题目描述

In this problem, you are given two positive integers n and m  and then n positive integer a1,a2,a3...an . 

Suppose that for each 1<=i<=n ,bi=(ai)!  . You should find  mod m

输入

The number of test cases comes in the first line. 

For each test case, first there are two integers  n and m such that 1<=n<=100,1<m<100000 . Then you are given  a1,a2,a3...an.

输出

For each test case, print  mod m

样例输入 复制

1
2 100
3 8

样例输出 复制

76

来源/分类