from collections import* (n,m),*e=[[*map(int,s.split())]for s in open(0)] uv,st=e[:-m],e[-m:] c=defaultdict(int) ns=set() for s,t in st: s-=1;t-=1 c[s,t]+=1 ns.add((s,t)) ans=[0] uf=[*range(n)] def find(x): q=[] while uf[x]^x:q+=x,;x=uf[x] for p in q:uf[p]=x return x def unite(x,y): x,y=find(x),find(y) if x^y:uf[x]=y for i in range(n-1)[::-1]: u,v=e[i] unite(u-1,v-1) ans+=ans[-1], q=set() for s,t in ns: if find(s)==find(t): q.add((s,t)) ans[-1]+=c[s,t] ns-=q print(*ans[:-1][::-1],sep='\n')