#include #include #include #include #include #include #include #include #include #include using namespace std; class UnionFindTree{ typedef struct { int parent; int rank; }base_node; vector node; public: UnionFindTree(int n){ node.resize(n); for(int i=0; i node[y].rank){ node[y].parent = x; }else{ node[x].rank++; unite(x,y); } } }; #include typedef bitset<100000> bits; #include int main(){ int n,m; cin >> n >> m; vector> g(n); UnionFindTree uft(n); for(int i=0; i cnt(n, 0); for(int i=0; i w; vector unko; for(int i=0; i x(unko.size()); for(int i=0; i0; k--){ x[k] |= x[k-1]< ans(n+1, -1); for(int i=1; i<=n; i++){ auto check = [&](int pos){ return x[pos][i]; }; long long lb = -1; long long ub = unko.size()-1; while(ub-lb>1){ long long mid = (lb+ub)/2; bool ok = check(mid); (ok? ub : lb) = mid; } /* if(check[ub]){ ans[i] = ub; } */ printf("%d\n", check(ub)?ub:-1); } return 0; }