Problem:
G： ほぼ無限グリコ - Almost Infinite Glico
問題
N
個のマスが円環状に並んでいるフィールドがあります。
i
番目
(1 \leq i \leq N-1)
のマスの
1
つ先は、
i+1
番目のマスになります。ただし、
i = N
の場合、その
1
つ先は
1
番目のマスになります。
あなたが最初にいるマスは
1
番目のマスです。そこから以下のルールに従って、じゃんけんを
K
回続けて行います。このとき、あなたと相手は特殊なじゃんけんを会得しているので、じゃんけんの勝ち方が
M
通りあります。
相手とじゃんけんを行い、あなたが相手に勝ったとき、今出した手、すなわち勝ち方
i
に応じたマス数
p_i
だけ進みます。負けたときはその場に留まります。
K
回のじゃんけんを終えたあとに、あなたが
i
番目のマスにいる場合の数を
1,000,000,007
で割った余りを、それぞれのマスについて求めてください。ここで
2
つの場合が異なるとは、
K
回のじゃんけんの各回のうち負けた回が一度でも異なる、または勝ち方が異なる回が一度でも存在することを言います。勝ち方も区別することに注意してください。また、それぞれの勝ち方について、発生する可能性が全くないものは存在しないこととします。
入力形式
入力は
1 + M
行与えられる。
N
M
K
p_1
...
p_M
1
行目では、マスの数
N
、 じゃんけんの勝ち方の数
M
、 じゃんけんを行う回数
K
が与えられる。
続いて
M
行与えられる。
i+1
行目では、
i
番目の勝ち方をした時に進めるマスの数
p_i
が与えられる。
制約
1 \leq N \leq 8 \times 10^2
1 \leq M \leq 10^4
1 \leq K \leq 10^9
1 \leq p_i \leq 10^9
出力形式
出力は
N
行からなる。
i
行目では、
K
回のじゃんけんを終えたあとにあなたが
i
番目のマスにいる場合の数を出力せよ。
入力例1
10 3 2
3
6
6
出力例1
1
0
4
2
0
0
5
0
0
4
一般的なグリコです。この入力において、じゃんけんは
2
回行われます。
例えば、
2
回じゃんけんをした後に
1
番目のマスにいるためには、全てのじゃんけんで負けなければいけません。これ以外に
1
番目のマスで終わる組み合わせは存在しないため、
1
通りです。
2
回じゃんけんをした後に
4
番目のマスにいるためには、
1
回目のじゃんけんで
1
番目の勝ち方で勝つ →
2
回目のじゃんけんで負ける
1
回目のじゃんけんで負ける →
2
回目のじゃんけんで
1
番目の勝ち方で勝つ
の
2
通りがあります。順番が異なるならば、異なる場合として扱われることに注意してください。
入力例2
5 1 103
4
出力例2
355272559
885073297
355272559
607675915
607675915
1,000,000,007
で割った余りを出力することに注意してください。

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=2167167167167167167;
const int INF=2100000000;
const ll mod=1e9+7;
#define rep(i,a) for (int i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}
template<class T> T min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}


void solve();
// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin>>t;
	rep(i,t) solve();
}

void solve(){
	ll N,M,K;
	cin>>N>>M>>K;
	vector<ll> p(N);
	rep(i,M){
		int a;
		cin>>a;
		p[a%N]++;
	}
	p[0]++;
	auto mul=[&](vector<ll> A,vector<ll> B)->vector<ll>{
		vector<ll> C(N);
		rep(i,N) rep(j,N){
			C[(i+j)%N]+=(A[i]*B[j])%mod;
		}
		rep(i,N) C[i]%=mod;
		return C;
	};
	vector<ll> ans(N);
	ans[0]=1;
	while(K){
		if(K&1) ans=mul(ans,p);
		p=mul(p,p);
		K>>=1;
	}
	rep(i,N) cout<<ans[i]<<"\n";
}
accuracy: 1
time_ms: 190
memory_kb: 3476
final_rank: 7

code_snippet: #include <bits/stdc++.h>
/* S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
clock()/CLOCKS_PER_SEC で秒数
vector v.push_back(x),v.pop_back()
q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
<deque>(push/pop)_(front/back)/fornt/back/insert/
priority_queue 宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに*/
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repl(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;(i)--)
#define vep(i,v) for(auto (i)=v.begin();(i)<(v.end());(i)++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }

const long long inf = 10e17;

//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
#define print(i) std::cout << (i) << '\n'
typedef  vector<ll> vec;
typedef vector<vec> mat ;
const ll mod =1000000007;
vec mul(vec &A,vec &B){
    vec ret(A.size(),0ll);
    int n=A.size();
    rep(i,n){
      rep(j,n){
        ret[(i+j)%n]=(ret[(i+j)%n]+A[i]*B[j]%mod)%mod;
      }
    }
    return ret;
}
vec pow(vec A,ll n){
    vec ret(A.size(),0ll);
    ret[0]=1ll;
    while(n>0ll){
        if(n&1ll)ret=mul(ret,A);
        A=mul(A,A);
        n>>=1ll;
    }
    return ret;
}
int main(){
int n,m;
ll k;
cin>>n>>m>>k;
vec a(n,0ll);
a[0]++;
rep(b,m){
    int p;
    cin>>p;
    p%=n;
    a[p]++;
}

vec V=pow(a,k);
rep(i,n){
    cout<<V[i]<<endl;
}
}
accuracy: 1
time_ms: 100
memory_kb: 3176
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
const ll LINF = 0x1fffffffffffffff;
const ll MOD = 1000000007;
#define name3(_1,_2,_3,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) name3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define each(i,a) for(auto &i : a)
#define sum(a) accumulate(all(a), 0LL)
#define all(i) begin(i), end(i)
template<class T, class U> inline bool chmin(T &a, const U &b){ if(a > b) { a = b; return 1; } else return 0; }
template<class T, class U> inline bool chmax(T &a, const U &b){ if(a < b) { a = b; return 1; } else return 0; }


ll n;
struct T{
    ll cnt[800] = {};
    T operator*(const T& a) const {
        T ans;
        rep(n)rep(j,n)ans.cnt[(i+j)%n]+=cnt[i]*a.cnt[j]%MOD;
        each(i,ans.cnt)i%=MOD;
        return ans;
    }
    T pow(ll x) const {
        T ans, a = *this;
        ans.cnt[0]  = 1;
        while(x){
            if(x & 1) ans = ans * a;
            a = a * a;
            x >>= 1;
        }
        return ans;
    }
};
int main(){
    ll m, k;
    cin >> n >> m >> k;
    T ans;
    ans.cnt[0] = 1;
    rep(m){
        ll p;
        cin >> p;
        ans.cnt[p % n]++;
    }
    ans = ans.pow(k);
    rep(n) cout << ans.cnt[i] << endl;
}
accuracy: 1
time_ms: 420
memory_kb: 3132
final_rank: 14

code_snippet: #include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
constexpr ll INF = 1ll<<30;
constexpr ll MOD = 1000000007;
//---------------------------------//

ll dp[32][800];
ll dp2[32][800];

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> P(M);
	REP(i, M) {
		scanf("%d", &P[i]);
		P[i] %= N;
	}
	
	++dp[0][0];
	REP(i, M) ++dp[0][P[i] % N];
	
	REP(t, 31) REP(i, N) REP(j, N) {
		(dp[t + 1][(i + j) % N] += dp[t][i] * dp[t][j] % MOD) %= MOD;
	}
	
	dp2[31][0] = 1;
	for (int t = 30; t >= 0; --t) {
		if (K >> t & 1) {
			REP(i, N) {
				REP(j, N) {
					(dp2[t][(i + j) % N] += dp2[t + 1][i] * dp[t][j] % MOD) %= MOD;
				}
			}
		}
		else {
			REP(i, N) dp2[t][i] = dp2[t + 1][i];
		}
	}
	REP(i, N) printf("%lld\n", dp2[0][i]);
	return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 3644
final_rank: 5

code_snippet: #include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }

std::vector<mint> mul(std::vector<mint>& a, std::vector<mint>&b) {
	int n=a.size();
	std::vector<mint> c(n,0);
	rep(i,n) rep(j,n) c[(i+j)%n]+=a[i]*b[j];
	return c;
}
std::vector<mint> pow(std::vector<mint>&a, lnt k) { int n=a.size(); std::vector<mint> r(n,0),t=a;r[0]=1; while(k){ if(k&1) r=mul(r,t); t=mul(t,t); k>>=1; } return r; }

int main() {
	int n,m,k;
	std::cin >> n >> m >> k;
	std::vector<mint> a(n,0);
	a[0]=1;
	rep(i,m) {
		int p;
		std::cin >> p;
		a[p%n]+=mint(1);
	}
	debug(a);
	auto c=pow(a,k);
	debug(c);
	rep(i,n) print(c[i]);
}
accuracy: 1
time_ms: 230
memory_kb: 3236
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
const ll LINF = 0x1fffffffffffffff;
const ll MOD = 1000000007;
#define name3(_1,_2,_3,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) name3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define each(i,a) for(auto &i : a)
#define sum(a) accumulate(all(a), 0LL)
#define all(i) begin(i), end(i)
template<class T, class U> inline bool chmin(T &a, const U &b){ if(a > b) { a = b; return 1; } else return 0; }
template<class T, class U> inline bool chmax(T &a, const U &b){ if(a < b) { a = b; return 1; } else return 0; }


ll n;
struct T{
    ll cnt[800] = {};
    T operator*(const T& a) const {
        T ans;
        rep(n)rep(j,n)ans.cnt[(i+j)%n]+=cnt[i]*a.cnt[j]%MOD;
        each(i,ans.cnt)i%=MOD;
        return ans;
    }
    T pow(ll x) const {
        T ans, a = *this;
        ans.cnt[0]  = 1;
        while(x){
            if(x & 1) ans = ans * a;
            a = a * a;
            x >>= 1;
        }
        return ans;
    }
};
int main(){
    ll m, k;
    cin >> n >> m >> k;
    T ans;
    ans.cnt[0] = 1;
    rep(m){
        ll p;
        cin >> p;
        ans.cnt[p % n]++;
    }
    ans = ans.pow(k);
    rep(n) cout << ans.cnt[i] << endl;
}
accuracy: 1
time_ms: 420
memory_kb: 3132
final_rank: 14

code_snippet: #include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using usize = std::size_t;
using u64 = std::uint64_t;

static constexpr u64 mod = 1000000007;

int main() {
  usize n, m;
  std::cin >> n >> m;
  u64 k;
  std::cin >> k;

  const auto mul = [&](std::vector<u64> &a, const std::vector<u64> &b) {
    std::vector<u64> c(n * 2, 0);
    for (usize i = 0; i != n; ++i) {
      for (usize j = 0; j != n; ++j) {
        c[i + j] = (c[i + j] + a[i] * b[j]) % mod;
      }
    }
    for (usize i = 0; i != n; ++i) {
      a[i] = (c[i] + c[n + i]) % mod;
    }
  };

  std::vector<u64> v(n, 0);
  v[0] += 1;
  for (usize i = 0; i != m; ++i) {
    usize p;
    std::cin >> p;
    p %= n;
    v[p] += 1;
  }

  std::vector<u64> ans(n, 0);
  ans[0] = 1;

  while (k != 0) {
    if (k % 2 != 0) {
      mul(ans, v);
    }
    mul(v, v);
    k /= 2;
  }

  for (const auto e : ans) {
    std::cout << e << "\n";
  }

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3132
final_rank: 1

code_snippet: #include <iostream>
#include <vector>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

using mint = modint<(int)1e9+7>;

vector<mint> prod(const vector<mint>& A, const vector<mint>& B){
  int n = A.size();
  vector<mint> ret(n);
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      ret[(i+j)%n] += B[j]*A[i];
    }
  }
  return ret;
}

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<mint> D(N);
  D[0] += 1;
  for(int i = 0; i < M; ++i){
    int p;
    cin >> p;
    // D[((-p)%N+N)%N] += 1;
    D[p%N] += 1;
  }
  vector<mint> ans(N);
  ans[0] += 1;
  // for(int i = 0; i < K; ++i){
  //   ans = prod(ans,D);
  //   for(auto e : ans){
  //     cerr << e << " ";
  //   }
  //   cerr << endl;
  // }
  while(K > 0){
    if(K&1){
      ans = prod(D,ans);
    }
    D = prod(D,D);
    K /= 2;
  }
  for(auto e : ans)
    cout << e << "\n";
}
accuracy: 1
time_ms: 210
memory_kb: 3116
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
ll mod = 1e9+7;

int main(){
 ll n,m,kk;
 cin>>n>>m>>kk;
 vector<vector<ll> > dp(32, vector<ll>(n,0) );
 dp[0][0]++;
 for(ll i=0;i<m;i++){
  ll tmp;
  cin>>tmp;
  //tmp--;
  dp[0][tmp%n]++;
 }
 for(ll i=1;i<32;i++){
  for(ll j=0;j<n;j++){
   for(ll k=0;k<n;k++){
    dp[i][(j+k)%n] += (dp[i-1][j]*dp[i-1][k])%mod;
    dp[i][(j+k)%n] %= mod;
   }
  }
 }

 vector<ll> ans(n,0);
 ans[0] = 1;
 
 for(ll i=0;i<32;i++){
  if( (kk>>i)&1 ){
   vector<ll> tmp(n,0);
   for(ll j=0;j<n;j++){
    for(ll k=0;k<n;k++){
     tmp[(j+k)%n] += (ans[j]*dp[i][k])%mod;
     tmp[(j+k)%n] %= mod;
    }
   }
   ans = tmp;
  }
 }

 for(auto i:ans)cout<<i<<endl;


    return 0;
}
accuracy: 1
time_ms: 720
memory_kb: 3284
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

int main()
{
  ll n,m,k;cin>>n>>m>>k;
  vector<int> p(m);
  ll i,j,l;
  rep(i,m)cin>>p[i];
  ll num=1;
  ll needs=0;
  while(num<=k)
  {
    num*=2;
    needs++;
  }
  vector<vector<ll>> con(needs+2,vector<ll>(n,0));
  rep(i,m)
  {
    con[0][p[i]%n]++;
  }
  con[0][0]++;
  for(i=1;i<=needs+1;i++)
  {
    rep(j,n)
    {
      rep(l,n)
      {
        con[i][(j+l)%n]+=con[i-1][l]*con[i-1][j];
        con[i][(j+l)%n]%=MOD;
      }
    }
  }
  ll left=k;
  ll nowi=0;
  vector<ll> ans(n,0);
  ans[0]=1;
  vector<ll> nans(n,0);
  while(left>0)
  {
    if(left%2==1)
    {
      rep(j,n)
      {
        rep(l,n)
        {
          nans[(j+l)%n]+=con[nowi][l]*ans[j];
          nans[(j+l)%n]%=MOD;
        }
      }
      rep(j,n)
      {
        ans[j]=nans[j];
        nans[j]=0;
      }
    }
    left/=2;
    nowi++;
  }
  rep(j,n)cout<<ans[j]<<endl;
}
accuracy: 1
time_ms: 410
memory_kb: 3272
final_rank: 13

code_snippet: #include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< class T >
struct Matrix {
  vector< vector< T > > A;

  Matrix() {}

  Matrix(size_t n, size_t m) : A(n, vector< T >(m, 0)) {}

  Matrix(size_t n) : A(n, vector< T >(n, 0)) {};

  size_t height() const {
    return (A.size());
  }

  size_t width() const {
    return (A[0].size());
  }

  inline const vector< T > &operator[](int k) const {
    return (A.at(k));
  }

  inline vector< T > &operator[](int k) {
    return (A.at(k));
  }

  static Matrix I(size_t n) {
    Matrix mat(n);
    for(int i = 0; i < n; i++) mat[i][i] = 1;
    return (mat);
  }

  Matrix &operator+=(const Matrix &B) {
    size_t n = height(), m = width();
    assert(n == B.height() && m == B.width());
    for(int i = 0; i < n; i++)
      for(int j = 0; j < m; j++)
        (*this)[i][j] += B[i][j];
    return (*this);
  }

  Matrix &operator-=(const Matrix &B) {
    size_t n = height(), m = width();
    assert(n == B.height() && m == B.width());
    for(int i = 0; i < n; i++)
      for(int j = 0; j < m; j++)
        (*this)[i][j] -= B[i][j];
    return (*this);
  }

  Matrix &operator*=(const Matrix &B) {
    size_t n = height(), m = B.width(), p = width();
    assert(p == B.height());
    vector< vector< T > > C(n, vector< T >(m, 0));
    for(int i = 0; i < n; i++)
      for(int j = 0; j < m; j++)
        for(int k = 0; k < p; k++)
          C[i][j] = (C[i][j] + (*this)[i][k] * B[k][j]);
    A.swap(C);
    return (*this);
  }

  Matrix &operator^=(long long k) {
    Matrix B = Matrix::I(height());
    while(k > 0) {
      if(k & 1) B *= *this;
      *this *= *this;
      k >>= 1LL;
    }
    A.swap(B.A);
    return (*this);
  }

  Matrix operator+(const Matrix &B) const {
    return (Matrix(*this) += B);
  }

  Matrix operator-(const Matrix &B) const {
    return (Matrix(*this) -= B);
  }

  Matrix operator*(const Matrix &B) const {
    return (Matrix(*this) *= B);
  }

  Matrix operator^(const long long k) const {
    return (Matrix(*this) ^= k);
  }

  friend ostream &operator<<(ostream &os, Matrix &p) {
    size_t n = p.height(), m = p.width();
    for(int i = 0; i < n; i++) {
      os << "[";
      for(int j = 0; j < m; j++) {
        os << p[i][j] << (j + 1 == m ? "]\n" : ",");
      }
    }
    return (os);
  }


  T determinant() {
    Matrix B(*this);
    assert(width() == height());
    T ret = 1;
    for(int i = 0; i < width(); i++) {
      int idx = -1;
      for(int j = i; j < width(); j++) {
        if(B[j][i] != 0) idx = j;
      }
      if(idx == -1) return (0);
      if(i != idx) {
        ret *= -1;
        swap(B[i], B[idx]);
      }
      ret *= B[i][i];
      T vv = B[i][i];
      for(int j = 0; j < width(); j++) {
        B[i][j] /= vv;
      }
      for(int j = i + 1; j < width(); j++) {
        T a = B[j][i];
        for(int k = 0; k < width(); k++) {
          B[j][k] -= B[i][k] * a;
        }
      }
    }
    return (ret);
  }
};

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

template< typename T >
struct FormalPowerSeries : vector< T > {
  using vector< T >::vector;
  using P = FormalPowerSeries;

  using MULT = function< P(P, P) >;
  using FFT = function< void(P &) >;

  static MULT &get_mult() {
    static MULT mult = nullptr;
    return mult;
  }

  static void set_mult(MULT f) { get_mult() = f; }

  static FFT &get_fft() {
    static FFT fft = nullptr;
    return fft;
  }

  static FFT &get_ifft() {
    static FFT ifft = nullptr;
    return ifft;
  }

  static void set_fft(FFT f, FFT g) {
    get_fft() = f;
    get_ifft() = g;
  }

  void shrink() {
    while(this->size() && this->back() == T(0)) this->pop_back();
  }

  P operator+(const P &r) const { return P(*this) += r; }

  P operator+(const T &v) const { return P(*this) += v; }

  P operator-(const P &r) const { return P(*this) -= r; }

  P operator-(const T &v) const { return P(*this) -= v; }

  P operator*(const P &r) const { return P(*this) *= r; }

  P operator*(const T &v) const { return P(*this) *= v; }

  P operator/(const P &r) const { return P(*this) /= r; }

  P operator%(const P &r) const { return P(*this) %= r; }

  P &operator+=(const P &r) {
    if(r.size() > this->size()) this->resize(r.size());
    for(int i = 0; i < r.size(); i++) (*this)[i] += r[i];
    return *this;
  }

  P &operator+=(const T &r) {
    if(this->empty()) this->resize(1);
    (*this)[0] += r;
    return *this;
  }

  P &operator-=(const P &r) {
    if(r.size() > this->size()) this->resize(r.size());
    for(int i = 0; i < r.size(); i++) (*this)[i] -= r[i];
    shrink();
    return *this;
  }

  P &operator-=(const T &r) {
    if(this->empty()) this->resize(1);
    (*this)[0] -= r;
    shrink();
    return *this;
  }

  P &operator*=(const T &v) {
    const int n = (int) this->size();
    for(int k = 0; k < n; k++) (*this)[k] *= v;
    return *this;
  }

  P &operator*=(const P &r) {
    if(this->empty() || r.empty()) {
      this->clear();
      return *this;
    }
    assert(get_mult() != nullptr);
    return *this = get_mult()(*this, r);
  }

  P &operator%=(const P &r) { return *this -= *this / r * r; }

  P operator-() const {
    P ret(this->size());
    for(int i = 0; i < this->size(); i++) ret[i] = -(*this)[i];
    return ret;
  }

  P &operator/=(const P &r) {
    if(this->size() < r.size()) {
      this->clear();
      return *this;
    }
    int n = this->size() - r.size() + 1;
    return *this = (rev().pre(n) * r.rev().inv(n)).pre(n).rev(n);
  }

  P pre(int sz) const { return P(begin(*this), begin(*this) + min((int) this->size(), sz)); }

  P operator>>(int sz) const {
    if(this->size() <= sz) return {};
    P ret(*this);
    ret.erase(ret.begin(), ret.begin() + sz);
    return ret;
  }

  P operator<<(int sz) const {
    P ret(*this);
    ret.insert(ret.begin(), sz, T(0));
    return ret;
  }

  P rev(int deg = -1) const {
    P ret(*this);
    if(deg != -1) ret.resize(deg, T(0));
    reverse(begin(ret), end(ret));
    return ret;
  }

  P diff() const {
    const int n = (int) this->size();
    P ret(max(0, n - 1));
    for(int i = 1; i < n; i++) ret[i - 1] = (*this)[i] * T(i);
    return ret;
  }

  P integral() const {
    const int n = (int) this->size();
    P ret(n + 1);
    ret[0] = T(0);
    for(int i = 0; i < n; i++) ret[i + 1] = (*this)[i] / T(i + 1);
    return ret;
  }

  // F(0) must not be 0
  P inv(int deg = -1) const {
    assert(((*this)[0]) != T(0));
    const int n = (int) this->size();
    if(deg == -1) deg = n;
    if(get_fft() != nullptr) {
      P ret(*this);
      ret.resize(deg, T(0));
      return ret.inv_fast();
    }
    P ret({T(1) / (*this)[0]});
    for(int i = 1; i < deg; i <<= 1) {
      ret = (ret + ret - ret * ret * pre(i << 1)).pre(i << 1);
    }
    return ret.pre(deg);
  }

  // F(0) must be 1
  P log(int deg = -1) const {
    assert((*this)[0] == 1);
    const int n = (int) this->size();
    if(deg == -1) deg = n;
    return (this->diff() * this->inv(deg)).pre(deg - 1).integral();
  }

  P sqrt(int deg = -1) const {
    const int n = (int) this->size();
    if(deg == -1) deg = n;
    if((*this)[0] == T(0)) {
      for(int i = 1; i < n; i++) {
        if((*this)[i] != T(0)) {
          if(i & 1) return {};
          if(deg - i / 2 <= 0) break;
          auto ret = (*this >> i).sqrt(deg - i / 2) << (i / 2);
          if(ret.size() < deg) ret.resize(deg, T(0));
          return ret;
        }
      }
      return P(deg, 0);
    }

    P ret({T(1)});
    T inv2 = T(1) / T(2);
    for(int i = 1; i < deg; i <<= 1) {
      ret = (ret + pre(i << 1) * ret.inv(i << 1)) * inv2;
    }
    return ret.pre(deg);
  }

  // F(0) must be 0
  P exp(int deg = -1) const {
    assert((*this)[0] == T(0));
    const int n = (int) this->size();
    if(deg == -1) deg = n;
    if(get_fft() != nullptr) {
      P ret(*this);
      ret.resize(deg, T(0));
      return ret.exp_rec();
    }
    P ret({T(1)});
    for(int i = 1; i < deg; i <<= 1) {
      ret = (ret * (pre(i << 1) + T(1) - ret.log(i << 1))).pre(i << 1);
    }
    return ret.pre(deg);
  }


  P online_convolution_exp(const P &conv_coeff) const {
    const int n = (int) conv_coeff.size();
    assert((n & (n - 1)) == 0);
    vector< P > conv_ntt_coeff;
    for(int i = n; i >= 1; i >>= 1) {
      P g(conv_coeff.pre(i));
      get_fft()(g);
      conv_ntt_coeff.emplace_back(g);
    }
    P conv_arg(n), conv_ret(n);
    auto rec = [&](auto rec, int l, int r, int d) -> void {
      if(r - l <= 16) {
        for(int i = l; i < r; i++) {
          T sum = 0;
          for(int j = l; j < i; j++) sum += conv_arg[j] * conv_coeff[i - j];
          conv_ret[i] += sum;
          conv_arg[i] = i == 0 ? T(1) : conv_ret[i] / i;
        }
      } else {
        int m = (l + r) / 2;
        rec(rec, l, m, d + 1);
        P pre(r - l);
        for(int i = 0; i < m - l; i++) pre[i] = conv_arg[l + i];
        get_fft()(pre);
        for(int i = 0; i < r - l; i++) pre[i] *= conv_ntt_coeff[d][i];
        get_ifft()(pre);
        for(int i = 0; i < r - m; i++) conv_ret[m + i] += pre[m + i - l];
        rec(rec, m, r, d + 1);
      }
    };
    rec(rec, 0, n, 0);
    return conv_arg;
  }

  P exp_rec() const {
    assert((*this)[0] == T(0));
    const int n = (int) this->size();
    int m = 1;
    while(m < n) m *= 2;
    P conv_coeff(m);
    for(int i = 1; i < n; i++) conv_coeff[i] = (*this)[i] * i;
    return online_convolution_exp(conv_coeff).pre(n);
  }


  P inv_fast() const {
    assert(((*this)[0]) != T(0));

    const int n = (int) this->size();
    P res{T(1) / (*this)[0]};

    for(int d = 1; d < n; d <<= 1) {
      P f(2 * d), g(2 * d);
      for(int j = 0; j < min(n, 2 * d); j++) f[j] = (*this)[j];
      for(int j = 0; j < d; j++) g[j] = res[j];
      get_fft()(f);
      get_fft()(g);
      for(int j = 0; j < 2 * d; j++) f[j] *= g[j];
      get_ifft()(f);
      for(int j = 0; j < d; j++) {
        f[j] = 0;
        f[j + d] = -f[j + d];
      }
      get_fft()(f);
      for(int j = 0; j < 2 * d; j++) f[j] *= g[j];
      get_ifft()(f);
      for(int j = 0; j < d; j++) f[j] = res[j];
      res = f;
    }
    return res.pre(n);
  }

  P pow(int64_t k, int deg = -1) const {
    const int n = (int) this->size();
    if(deg == -1) deg = n;
    for(int i = 0; i < n; i++) {
      if((*this)[i] != T(0)) {
        T rev = T(1) / (*this)[i];
        P ret = (((*this * rev) >> i).log() * k).exp() * ((*this)[i].pow(k));
        if(i * k > deg) return P(deg, T(0));
        ret = (ret << (i * k)).pre(deg);
        if(ret.size() < deg) ret.resize(deg, T(0));
        return ret;
      }
    }
    return *this;
  }

  T eval(T x) const {
    T r = 0, w = 1;
    for(auto &v : *this) {
      r += w * v;
      w *= x;
    }
    return r;
  }

  P pow_mod(int64_t n, P mod) {
    P x(*this), ret{1};
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return ret;
  }
};

namespace FastFourierTransform {
  using real = double;

  struct C {
    real x, y;

    C() : x(0), y(0) {}

    C(real x, real y) : x(x), y(y) {}

    inline C operator+(const C &c) const { return C(x + c.x, y + c.y); }

    inline C operator-(const C &c) const { return C(x - c.x, y - c.y); }

    inline C operator*(const C &c) const { return C(x * c.x - y * c.y, x * c.y + y * c.x); }

    inline C conj() const { return C(x, -y); }
  };

  const real PI = acosl(-1);
  int base = 1;
  vector< C > rts = {{0, 0},
                     {1, 0}};
  vector< int > rev = {0, 1};


  void ensure_base(int nbase) {
    if(nbase <= base) return;
    rev.resize(1 << nbase);
    rts.resize(1 << nbase);
    for(int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    while(base < nbase) {
      real angle = PI * 2.0 / (1 << (base + 1));
      for(int i = 1 << (base - 1); i < (1 << base); i++) {
        rts[i << 1] = rts[i];
        real angle_i = angle * (2 * i + 1 - (1 << base));
        rts[(i << 1) + 1] = C(cos(angle_i), sin(angle_i));
      }
      ++base;
    }
  }

  void fft(vector< C > &a, int n) {
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for(int i = 0; i < n; i++) {
      if(i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for(int k = 1; k < n; k <<= 1) {
      for(int i = 0; i < n; i += 2 * k) {
        for(int j = 0; j < k; j++) {
          C z = a[i + j + k] * rts[j + k];
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
      }
    }
  }

  vector< int64_t > multiply(const vector< int > &a, const vector< int > &b) {
    int need = (int) a.size() + (int) b.size() - 1;
    int nbase = 1;
    while((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    vector< C > fa(sz);
    for(int i = 0; i < sz; i++) {
      int x = (i < (int) a.size() ? a[i] : 0);
      int y = (i < (int) b.size() ? b[i] : 0);
      fa[i] = C(x, y);
    }
    fft(fa, sz);
    C r(0, -0.25 / (sz >> 1)), s(0, 1), t(0.5, 0);
    for(int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      C z = (fa[j] * fa[j] - (fa[i] * fa[i]).conj()) * r;
      fa[j] = (fa[i] * fa[i] - (fa[j] * fa[j]).conj()) * r;
      fa[i] = z;
    }
    for(int i = 0; i < (sz >> 1); i++) {
      C A0 = (fa[i] + fa[i + (sz >> 1)]) * t;
      C A1 = (fa[i] - fa[i + (sz >> 1)]) * t * rts[(sz >> 1) + i];
      fa[i] = A0 + A1 * s;
    }
    fft(fa, sz >> 1);
    vector< int64_t > ret(need);
    for(int i = 0; i < need; i++) {
      ret[i] = llround(i & 1 ? fa[i >> 1].y : fa[i >> 1].x);
    }
    return ret;
  }
};


template< typename T >
struct ArbitraryModConvolution {
  using real = FastFourierTransform::real;
  using C = FastFourierTransform::C;

  ArbitraryModConvolution() = default;

  vector< T > multiply(const vector< T > &a, const vector< T > &b, int need = -1) {
    if(need == -1) need = a.size() + b.size() - 1;
    int nbase = 0;
    while((1 << nbase) < need) nbase++;
    FastFourierTransform::ensure_base(nbase);
    int sz = 1 << nbase;
    vector< C > fa(sz);
    for(int i = 0; i < a.size(); i++) {
      fa[i] = C(a[i].x & ((1 << 15) - 1), a[i].x >> 15);
    }
    fft(fa, sz);
    vector< C > fb(sz);
    if(a == b) {
      fb = fa;
    } else {
      for(int i = 0; i < b.size(); i++) {
        fb[i] = C(b[i].x & ((1 << 15) - 1), b[i].x >> 15);
      }
      fft(fb, sz);
    }
    real ratio = 0.25 / sz;
    C r2(0, -1), r3(ratio, 0), r4(0, -ratio), r5(0, 1);
    for(int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      C a1 = (fa[i] + fa[j].conj());
      C a2 = (fa[i] - fa[j].conj()) * r2;
      C b1 = (fb[i] + fb[j].conj()) * r3;
      C b2 = (fb[i] - fb[j].conj()) * r4;
      if(i != j) {
        C c1 = (fa[j] + fa[i].conj());
        C c2 = (fa[j] - fa[i].conj()) * r2;
        C d1 = (fb[j] + fb[i].conj()) * r3;
        C d2 = (fb[j] - fb[i].conj()) * r4;
        fa[i] = c1 * d1 + c2 * d2 * r5;
        fb[i] = c1 * d2 + c2 * d1;
      }
      fa[j] = a1 * b1 + a2 * b2 * r5;
      fb[j] = a1 * b2 + a2 * b1;
    }
    fft(fa, sz);
    fft(fb, sz);
    vector< T > ret(need);
    for(int i = 0; i < need; i++) {
      int64_t aa = llround(fa[i].x);
      int64_t bb = llround(fb[i].x);
      int64_t cc = llround(fa[i].y);
      aa = T(aa).x, bb = T(bb).x, cc = T(cc).x;
      ret[i] = aa + (bb << 15) + (cc << 30);
    }
    return ret;
  }
};


template< typename T >
FormalPowerSeries< T > berlekamp_massey(const FormalPowerSeries< T > &s) {
  const int N = (int) s.size();
  FormalPowerSeries< T > B(N), C(N);
  B[0] = C[0] = T(1);
  int L = 0, m = 1;
  T b{1};
  for(int n = 0; n < N; n++) {
    T d = s[n];
    for(int i = 1; i <= L; i++) d += C[i] * s[n - i];
    T inv_b = d / b;
    if(d == 0) {
      m++;
    } else if(2 * L <= n) {
      auto temp = C;
      for(int i = 0; i + m < N; i++) C[i + m] -= B[i] * inv_b;
      L = n + 1 - L;
      B = temp;
      b = d;
      m = 1;
    } else {
      for(int i = 0; i + m < N; i++) C[i + m] -= B[i] * inv_b;
      m++;
    }
  }
  C.resize(L + 1);
  reverse(C.begin(), C.end());
  assert(L < N - 1);
  return C;
}

template< typename T >
FormalPowerSeries< T > random_poly(int n) {
  mt19937 mt(1333333);
  FormalPowerSeries< T > res(n);
  uniform_int_distribution< int > rand(0, T::get_mod() - 1);
  for(int i = 0; i < n; i++) res[i] = rand(mt);
  return res;
}

template< typename T, typename F >
FormalPowerSeries< T > minimum_poly(int N, const F &nex) {
  auto dp = random_poly< T >(N);
  auto u = random_poly< T >(N);
  FormalPowerSeries< T > f(2 * N + 5);
  for(int i = 0; i < 2 * N + 5; i++) {
    for(int j = 0; j < N; j++) f[i] += u[j] * dp[j];
    dp = nex(dp);
  }
  return berlekamp_massey< T >(f);
}


template< typename T, typename F >
FormalPowerSeries< T > mat_mul(int N, int64_t Q, FormalPowerSeries< modint > dp, const F &nex) {
  auto A = FormalPowerSeries< T >({0, 1}).pow_mod(Q, minimum_poly< T >(N, nex));
  FormalPowerSeries< T > res(N);
  for(int i = 0; i < A.size(); i++) {
    res += dp * A[i];
    dp = nex(dp);
  }
  return res;
}

int main() {
  using FPS = FormalPowerSeries< modint >;
  ArbitraryModConvolution< modint > fft;
  //NumberTheoreticTransformFriendlyModInt< modint > fft;
  //FPS::set_fft([&](FPS &a) { fft.ntt(a); }, [&](FPS &a) { fft.intt(a); });
  FPS::set_mult([&](const FPS &a, const FPS &b) {
    auto c = fft.multiply(a, b);
    return FPS(begin(c), end(c));
  });

  int N, M, K;
  cin >> N >> M >> K;
  FPS P(N);
  P[0] += 1;
  for(int i = 0; i < M; i++) {
    int x;
    cin >> x;
    P[x % N] += 1;
  }

  FPS dp(N);
  dp[0] = 1;
  auto nex = [&](const FPS &a) {
    FPS buff = a * P;
    FPS c(N);
    for(int i = 0; i < buff.size(); i++) c[i % N] += buff[i];
    return c;
  };
  dp = mat_mul< modint >(N, K, dp, nex);
  for(int i = 0; i < N; i++) cout << dp[i] << "\n";
}
accuracy: 1
time_ms: 430
memory_kb: 3748
final_rank: 16

code_snippet: /*  -*- coding: utf-8 -*-
 *
 * 2844.cc: Almost Infinite Glico
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 800;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef int vec[MAX_N];

/* global variables */

vec av, bv, cv;
vec sv, tv;

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

inline void initvec(const int n, vec a) {
  memset(a, 0, sizeof(vec));
}

inline void copyvec(const int n, const vec a, vec b) {
  memcpy(b, a, sizeof(vec));
}

inline void mulvec(const int n, const vec a, const vec b, vec c) {
  initvec(n, c);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      addmod(c[(i + j) % n], (ll)a[i] * b[j] % MOD);
}

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);

  initvec(n, av);
  av[0] = 1;
  for (int i = 0; i < m; i++) {
    int pi;
    scanf("%d", &pi);
    av[pi % n]++;
  }

  initvec(n, bv);
  bv[0] = 1;
  while (k > 0) {
    if (k & 1) {
      mulvec(n, bv, av, sv);
      copyvec(n, sv, bv);
    }

    mulvec(n, av, av, sv);
    copyvec(n, sv, av);
    k >>= 1;
  }

  for (int i = 0; i < n; i++) printf("%d\n", bv[i]);
  return 0;
}
accuracy: 1
time_ms: 150
memory_kb: 3244
final_rank: 6

code_snippet: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
typedef vector<ll>  mat;
int sz;
mat mul(mat A,mat B){
   mat C(sz);
   rep(i,sz)rep(j,sz)C[(i+j)%sz]+=A[i]*B[j]%mod;
   rep(i,sz)C[i]%=mod;
   return C;
}

mat pow(mat A,ll k){
   mat B(sz);
   B[0]=1;
   while(k>0){
       if(k&1)B=mul(A,B);
       A=mul(A,A);
       k/=2;
   }
   return B;
}
int main(){
    cin>>sz;
    int m,k;
    cin>>m>>k;
    mat A(sz);
    int p[m];
    rep(i,m){
        cin>>p[i];
        A[p[i]%sz]++;
    }
    A[0]++;
    A=pow(A,k);
    rep(i,sz)cout<<A[i]<<endl;
    return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 3232
final_rank: 3

code_snippet: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



typedef vector<ll> V;
typedef vector<V> MATRIX;

int N,M;
ll table[10000];

MATRIX calc_ans(MATRIX left, MATRIX right){
    MATRIX RET(1,V(N));
    for(int col = 0; col < N; col++){
    	RET[0][col] = 0;
    	for(int row = 0; row < N; row++){
    		RET[0][col] += left[0][row]*right[row][col];
    		RET[0][col] %= MOD;
    	}
    }

    return RET;
}


MATRIX calc(MATRIX left,MATRIX right){

	MATRIX ret(N,V(N));

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)ret[i][k] = 0;
	}

	for(int col = 0; col < N; col++){
		ret[0][col] = 0;
		for(int row = 0; row < N; row++){
			ret[0][col] += left[0][row]*right[row][col];
			ret[0][col] %= MOD;
		}
	}

	for(int row = 0; row <= N-2; row++){
		for(int col = 0; col <= N-1; col++){
			ret[row+1][(col+1)%N] = ret[row][col];
		}
	}

	return ret;

}

MATRIX pow(MATRIX MULT,int count){

	MATRIX ret(N,V(N));

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			if(row == col)ret[row][col] = 1;
			else{
				ret[row][col] = 0;
			}
		}
	}

	while(count > 0){
		if(count%2 == 1)ret = calc(ret,MULT);
		MULT = calc(MULT,MULT);
		count /= 2;
	}

	return ret;
}



int main(){

	int K;
	scanf("%d %d %d",&N,&M,&K);

	for(int i = 0; i < M; i++){
		scanf("%lld",&table[i]);
		table[i] %= N;
	}

	ll work[N];
	work[0] = 1;
	for(int i = 1; i <= N-1; i++)work[i] = 0;

	for(int i = 0; i < M; i++){
		work[table[i]]++;
	}

	MATRIX first_state(1,V(N));
	first_state[0][0] = 1;

	for(int i = 1; i <= N-1; i++)first_state[0][i] = 0;

	MATRIX transition(N,V(N));
	for(int i = 0; i <= N-1; i++)transition[0][i] = work[i];

	for(int row = 0; row <= N-2; row++){
		for(int col = 0; col <= N-1; col++){
			transition[row+1][(col+1)%N] = transition[row][col];
		}
	}

	if(K > 1){
		transition = pow(transition,K);
	}

	MATRIX ans = calc_ans(first_state,transition);

	for(int i = 0; i < N; i++){
		printf("%lld\n",ans[0][i]%MOD);
	}

	return 0;
}
accuracy: 1
time_ms: 480
memory_kb: 33232
final_rank: 20

code_snippet: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

struct mat
{
    vvl v;
    mat(int n){
        v.resize(n,vl(n,0));
    }
};

ll add(ll x,ll y)
{
    return (x + y)%MOD;
}

ll sub(ll x,ll y)
{
    return (x+MOD-y)%MOD;
}

ll mul(ll x,ll y)
{
    return x*y%MOD;
}

mat mul(const mat& m1,const mat& m2)
{
    int MAX_N = len(m1.v);
    mat res(MAX_N);
    rep(i,MAX_N){
        rep(j,MAX_N){
            res.v[0][i] = add(res.v[0][i],mul(m1.v[0][j],m2.v[j][i]));
        }
    }
    srep(i,1,MAX_N){
        rep(j,MAX_N){
            res.v[i][j] = res.v[0][(j+MAX_N-i)%MAX_N];
        }
    }
    return res;
}

mat mod_pow(const mat& m1,ll b)
{
    int n = len(m1.v);
    mat res(n);
    rep(i,n){
        res.v[i][i] = 1;
    }
    mat nw(n);
    nw = m1;
    while(b){
        if(b & 1){
            res = mul(res,nw);
        }
        nw = mul(nw,nw);
        b >>= 1;
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,K;
    cin >> n >> m >> K;
    mat a(n);
    rep(i,n){
        a.v[i][i]++;
    }
    rep(i,m){
        int b;
        cin >> b;
        rep(j,n){
            a.v[j][(j+b)%n]++;
        }
    }
    mat res(n);
    res = mod_pow(a,K);
    rep(i,n){
        cout << res.v[0][i] << "\n";
    }
    return 0;
}
accuracy: 1
time_ms: 310
memory_kb: 27992
final_rank: 19

code_snippet: #include <iostream>
#include <vector>
using namespace std;

const long long p = 1000000007;

void printmat(const vector< int > &a)
{
  const int n = a.size();
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      cerr << a[(i+n-j)%n] << " ";
    }
    cerr << endl;
  }
}

// caution: b = a * b
void mulBy(const vector< int > &a, vector< int > &b, int n)
{
  vector< int > r(n);
  for(int i = 0; i < n; i++) {
    r[i] = b[i];
  }
  for(int j = 0; j < n; j++) {
    long long c = 0;
    for(int k = 0; k < n; k++) {
      c += (a[k] * (long long)r[(j+n-k)%n]) % p; // b'[i][j] += a[i][k] * b[k][j];
    }
    b[j] = (int)(c % p);
  }
}
// b = b * b
void pow2(vector< int > &b, int n)
{
  vector< int > r(n);
  for(int i = 0; i < n; i++) {
    r[i] = b[i];
  }
  mulBy(r, b, n);
}
// mat = mat^x
void pow(vector< int > &mat, int n, int x)
{
  vector< int > r(n);
  // eye
  for(int j = 0; j < n; j++) {
    r[j] = 0 == j ? 1 : 0;
  }
  while(x > 0) {
    if((x & 1) != 0) {
      mulBy(mat, r, n);
    }
    pow2(mat, n);
    x >>= 1;
  }
  for(int j = 0; j < n; j++) {
    mat[j] = r[j];
  }
}

int main(int argc, char *argv[])
{
  for(;;) {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> ps;
    for(int i = 0; i < m; i++) {
      int pi;
      cin >> pi;
      ps.push_back(pi);
    }

    // hist[i] .. possibilities of being on i
    // hist' = hist * mat
    //   where mat[i][j] is transition possibilities from i to j
    
    vector< int > mat(n);
    for(int j = 0; j < n; j++) {
      mat[j] = 0;
    }
    // kachi
    for(int j = 0; j < m; j++) {
      mat[(int)((ps[j]) % n)]++;
    }
    mat[0]++; // make
    //printmat(mat);
    pow(mat, n, k);
    for(int i = 0; i < n; i++) {
      cout << mat[i] << endl;
    }
    break;
  }
  return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3264
final_rank: 2

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat &A,mat &B){
	mat C(A.size(),vec(B[0].size()));
	for(int i=0;i<A.size();i++){
		for(int k=0;k<B.size();k++){
			for(int j=0;j<B[0].size();j++){
				C[i][j]=(C[i][j]+(A[i][k]*B[k][j]%MOD))%MOD;
			}
		}
	}
	return C;
}

mat pow(mat A,ll n){
	mat B(A.size(),vec(A.size()));
	for(int i=0;i<A.size();i++){
		B[i][i]=1;
	}
	while(n>0){
		if(n&1)B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}


int n,m,K;
ll p[10001];
ll nec[801];
ll res[30][801];
ll ans[2][801];

int main(void){
	scanf("%d%d%d",&n,&m,&K);
	mat B(n,vec(n));
	for(int i=0;i<m;i++){
		scanf("%d",&p[i]);
	}
	nec[0]++;
	for(int i=0;i<m;i++){
		int mo=p[i]%n;
		nec[mo]++;
	}
	for(int i=0;i<30;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(i>0)res[i][(j+k)%n]+=(res[i-1][j]*res[i-1][k])%MOD;
				if(i==0)res[i][j]=nec[j];
				if(res[i][(j+k)%n]>=MOD)res[i][(j+k)%n]%=MOD;
			}
		}
	}
	int prev=0,now=1;
	ans[0][0]=1;
	for(int i=0;i<30;i++){
		if(K>>i & 1){
			for(int j=0;j<n;j++){
				for(int k=0;k<n;k++){
					ans[now][(j+k)%n]+=(ans[prev][j]*res[i][k])%MOD;
					if(ans[now][(j+k)%n]>=MOD)ans[now][(j+k)%n]%=MOD;
				}
			}
			swap(now,prev);
			memset(ans[now],0,sizeof(ans[now]));
		}
	}
	for(int i=0;i<n;i++){
		printf("%lld\n",ans[prev][i]);
	}
	return 0;
}
accuracy: 1
time_ms: 230
memory_kb: 8276
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

const long long M=1e9+7;
typedef vector<long long> vec;
typedef vector<vec> mat;
struct Matrix{
  int N;
  mat a;
  Matrix(int n){
    N=n;
    a=mat(N,vec(N));
    for(int i=0;i<N;i++)a[i][i]=1;
  }
  Matrix pow(long long b) const {
    Matrix res(N);
    Matrix d(N);
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[i][j]=a[i][j];
    for(;b>0;b>>=1,d=d*d)if(b&1)res=d*res;
    return res;
  }
  Matrix operator+(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        s[i][j]=(a[i][j]+r.a[i][j])%M;
      }
    }
    return s;
  }
  Matrix operator*(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++)s[i][i]=0;
    const long long modl=8*M*M;
    //for(int i=0;i<N;i++){
      for(int k=0;k<N;k++){
        for(int j=0;j<N;j++){
          s[0][j]+=a[0][k]*r.a[k][j];
          if(s[0][j]>=modl)s[0][j]-=modl;
        }
      }
      for(int j=0;j<N;j++)s[0][j]%=M;
    //}
    for(int i=0;i<N-1;i++){
      for(int j=0;j<N;j++){
        s[i+1][(j+1)%N]=s[i][j];
      }
    }
    return s;
  }

  vector<long long>& operator[](int i){
    return a[i];
  }
};


ll n,m,k;
ll cnt[888];

int main(){
	cin>>n>>m>>k;
  rep(i,m){
    ll p;
    cin>>p;
    cnt[p%n]++;
  }
  Matrix mat(n);
  rep(i,n)rep(j,n){
    mat[i][(i+j)%n]+=cnt[j];
  }
  Matrix res=mat.pow(k);

  rep(i,n){
    cout<<res[0][i]<<endl;
  }
	return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 22980
final_rank: 17

code_snippet: #include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef vector<ll> row;
typedef vector<row> mat;

ll N, M, K, P[10000];

row mul(row &A, row &B) {
  row C(N);
  REP(i, 0, N)
    REP(j, 0, N)
      C[i] = (C[i] + A[j] * B[(i - j + N) % N]) % MOD;
  return C;
}

row pow(row A, ll n) {
  row B(N);
  B[0] = 1;
  while(n > 0) {
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}


int main(void) {
  cin >> N >> M >> K;
  REP(i, 0, M) cin >> P[i];

  row A(N);
  A[0]++;
  REP(i, 0, M) A[(N - P[i] % N) % N]++;
  A = pow(A, K);

  REP(i, 0, N) cout << A[(N - i) % N] << endl;
}
accuracy: 1
time_ms: 230
memory_kb: 3236
final_rank: 9

code_snippet: #include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef vector<ll> row;
typedef vector<row> mat;

ll N, M, K, P[10000];

row mul(row &A, row &B) {
  row C(N);
  REP(i, 0, N)
    REP(j, 0, N)
      C[i] = (C[i] + A[j] * B[(i - j + N) % N]) % MOD;
  return C;
}

row pow(row A, ll n) {
  row B(N);
  B[0] = 1;
  while(n > 0) {
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}


int main(void) {
  cin >> N >> M >> K;
  REP(i, 0, M) cin >> P[i];

  row A(N);
  A[0]++;
  REP(i, 0, M) A[P[i] % N]++;
  A = pow(A, K);

  REP(i, 0, N) cout << A[i] << endl;
}
accuracy: 1
time_ms: 230
memory_kb: 3252
final_rank: 11