#include //#pragma optimize ("O3") //#pragma target ("sse4") const int MAXN=200017; using namespace std; #define endl '\n' vector v, G[MAXN], G2[MAXN]; int a[MAXN], col[MAXN], comp[MAXN], in[MAXN], out[MAXN], used[MAXN], used2[MAXN], temp=0, cnt=0, n, m; vector> e; void dfs(int u) { used[u]=1; for(int i=0; i=0; i--) if(used2[v[i]]==0) temp=0, dfs2(v[i]), col[cnt++]=temp; } set gr[MAXN]; int usedit[MAXN], ans[MAXN]; void doit(int u) { usedit[u]=1; ans[u]=col[u]; for(int x: gr[u]) if(usedit[x]==0) doit(x); for(int x: gr[u]) ans[u]=max(ans[u], ans[x]); } void mainp() { freopen("promotion.in","r",stdin); freopen("promotion.out","w",stdout); cin>>n>>m; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=0; i>x>>y; G[x].push_back(y); G2[y].push_back(x); e.push_back({x, y}); } make(); for(int i=0; i