#pragma GCC target ("sse4") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using Int = long long; const char newl = '\n'; const unsigned int MOD = 1e9+7; // sum_{i=0}^{n-1} (ai + b) // m // 0 <= a, b template inline T sum_of_floor(T n,T a){ T res=0; while(1){ if(a>=n){ res+=(n-1)*n*(a/n)/2; a%=n; } T y=a; if(y==0) return res; T nn=y; T na=n; n=nn; a=na; } cout<>n>>m; for(ull i=0;i>as[i]; for(ull j=0;j>bs[j]; vector ans(m); for(ull i=0;i