#include //以下cout時の色設定 #define COUTRESET "\033[0m" // 色をリセット #define COUTRED "\033[31m" // 赤色 #define COUTGREEN "\033[32m" // 緑色 #define COUTYELLOW "\033[33m" // 黄色 #define COUTBLUE "\033[34m" // 青色 using namespace std; using ll=long long; using ld=long double; using P=pair; const ll INF=9*1e15; const vector dx={0,0,1,-1}; const vector dy={1,-1,0,0}; #define rep(i,N) for(int i=0;i ostream& operator<<(ostream &os,pair &P){ return os<<"("< ostream& operator<<(ostream &os,vector vec){ for(auto val:vec){ os< void print(const T &vec){ int i=0; for(auto val:vec){ cout< void print2(const vector> &vec){ int i=0; for(auto v:vec){ cout< void chmin(T &a,T b){ if(a>b){ a=b; } return; } template void chmax(T &a,T b){ if(a struct DualSegtree{ int siz; int N; int log; vector data; int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } DualSegtree(){} DualSegtree(int n){ N=n; log=ceil_pow2(n); siz=1< &vec){ N=(int)vec.size(); log=ceil_pow2(N); siz=1<>=1; r>>=1; } return; } T get(int p){ assert(0<=p && psync_with_stdio(0); ll N,F; cin>>N>>F; vector> hand(N,vector(3)); rep(i,3){ rep(j,N){ cin>>hand[j][i]; } } queue> que; que.push({0,0}); vector ans(N+1); ans[0]=0; int now=0; vector seen(F*N+10,-1); while(!que.empty()){ P v=que.front(); que.pop(); now=v.second; if(seen[v.first]==now){ continue; } seen[v.first]=now; ans[now]++; if(now==N){ continue; } for(int i=0;i<3;i++){ que.push({v.first+hand[now][i],now+1}); } } for(int i=1;i<=N;i++){ cout<