Closing the Farm (Silver)#10573

Closing the Farm (Silver)

1 second
128 megabytes
Medium

Farmer John and his cows are planning to leave town for a long vacation, so FJ wants to temporarily close his farm to save money while they are away.

The farm consists of barns connected by bidirectional paths. Each path connects a pair of barns. To shut down the farm, FJ plans to close one barn at a time. When a barn is closed, all paths connected to that barn are also closed and can no longer be used.

FJ wants to know, at each point in time (initially and after each barn is closed), whether his farm is "fully connected." This means that it must be possible to travel from any open barn to any other open barn using a sequence of open paths. Since FJ's farm is initially somewhat in a state of disrepair, it may not be fully connected to begin with.

Input

The first line contains two integers and m~(1 \le n, m \le 3000).

The next lines each describe a path by giving the pair of barns it connects. The barns are numbered from to .

The final lines contain a permutation of the integers from to , describing the order in which the barns will be closed.

Output

Print n + 1 lines, each containing "" or "".

The first line indicates whether the initial farm is fully connected. Line i+1 indicates whether the farm is fully connected after the -th barn has been closed.

Examples

Example 1

Loading
Loading