405254: GYM101858 F Frieza Frenzy
Description
"I doubt I need an introduction, but just in case, I am the mighty Frieza, and yes, all the horrible stories you've heard are true."
Frieza arrived on Earth and is seeking for Goku.
He's not so patient, so he decided to destroy roads, one by one, until Goku appears.
As Frieza destroy roads, some regions get disconnected and people on some places can't get to some other places. A set of places is said to be connected if, from any place on this set, it's possible to reach every other place on it and no place outside it.
The Central City has $$$n$$$ places and $$$m$$$ bidirectional roads that connect two distinct places. Initially the city is connected.
Goku doesn't care about Frieza at all and will let Frieza destroy all roads. Meanwhile, he decided to count the number of connected sets of places in Central City every time Frieza destroy a road. You don't care about Frieza also, so you will help Goku.
InputThe first line of input contains two integers, $$$n$$$ and $$$m$$$ ($$$2 \le n \le 10^5$$$, $$$n-1 \le m \le min(n \times (n-1) / 2, 10^5$$$) — the number of places and roads at Central City.
The next $$$m$$$ lines contains, each, two integers, $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$) — the places the $$$i$$$-th road connects.
The next line contains $$$m$$$ numbers, a permutation of all numbers between $$$1$$$ and $$$m$$$ — the sequence of roads destroyed by Frieza.
It's guaranteed that there's no more than one road that connects $$$u$$$ and $$$v$$$, for every $$$u$$$ and $$$v$$$.
OutputFor each road destroyed, print the number of connected sets of places in Central City.
ExamplesInput6 6Output
1 2
1 3
2 3
3 4
4 5
4 6
5 4 2 1 6 3
2Input
3
3
4
5
6
4 6Output
1 2
1 3
1 4
2 3
2 4
3 4
3 4 1 5 2 6
1
1
1
2
3
4