#include using namespace std; typedef long long ll; const int N = 100000 + 10; const int M = 1000000007; const double eps = 1e-9; const double PI = acos(-1); const int oo = 1000000000; typedef vector vi; typedef vector vvi; typedef pair ii; #define pb push_back #define all(c) (c).begin(),(c).end() int n,m,dp[N],l,r,seg[2][4*N],lz[2][4*N],typ[N],to[N]; vector > g; void fix(int u, int s, int e, bool f){ if(s!=e){ lz[f][u*2]+=lz[f][u]; lz[f][u*2+1]+=lz[f][u]; } seg[f][u]+=lz[f][u]; lz[f][u]=0; } int get(int u, int s, int e, bool f){ fix(u,s,e,f); if(s>r || e=l && e<=r) return seg[f][u]; return max(get(u*2,s,(s+e)/2,f),get(u*2+1,(s+e)/2+1,e,f)); } void update(int u, int s, int e, bool f, int val){ fix(u,s,e,f); if(s>r || e=l && e<=r){ lz[f][u]+=val; fix(u,s,e,f); return; } update(u*2,s,(s+e)/2,f,val); update(u*2+1,(s+e)/2+1,e,f,val); seg[f][u]=max(seg[f][u*2], seg[f][u*2+1]); } int main(){ #ifndef ONLINE_JUDGE //freopen("input.txt", "r", stdin); #endif int T; cin>>T; while(T--){ cin>>n>>m; g.clear(); g.resize(n+1); memset(typ,0,sizeof(typ)); for(int i=0; ia)continue; g[a].pb(ii(to[i],typ[i])); } memset(lz,0,sizeof(lz)); memset(seg,0,sizeof(seg)); for(int i=1; i<=n; ++i){ for(int j=0; jn) printf("-1 "); else printf("%d ", j); } puts(""); } return 0; }