-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path10489.cpp
28 lines (27 loc) · 838 Bytes
/
10489.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
int test;
scanf("%d",&test);
while(test--){
int total,lines,i,value=0;
scanf("%d%d",&total,&lines);
for(i=0;i<lines;i++){
int n;
int val=1;
scanf("%d",&n);
while(n--){
int toffee;
scanf("%d",&toffee);
val=(val*toffee)%total;
}
value+=val;
}
value%=total;
printf("%d\n",value);
}
return 0;
}