#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>=1; return r; } void solve() { int i,j,k,l,r,x,y; string s; cin>>X>>N; ll ret=0; FOR(i,N) cin>>y, ret += modpow(X,y); cout<