405254: GYM101858 F Frieza Frenzy

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Frieza Frenzytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

"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.

Input

The 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$$$.

Output

For each road destroyed, print the number of connected sets of places in Central City.

ExamplesInput
6 6
1 2
1 3
2 3
3 4
4 5
4 6
5 4 2 1 6 3
Output
2
3
3
4
5
6
Input
4 6
1 2
1 3
1 4
2 3
2 4
3 4
3 4 1 5 2 6
Output
1
1
1
2
3
4

Source/Category

加入题单

算法标签: