SP28457 TAP2016C - Correlations
Description
**\[Due to SPOJ restrictions, this problem has been modified with respect to the original version used in the Argentinian Programming Tournament of 2016 in order to have multiple test cases per input file. The original version of this problem (in Spanish) can be found at \]**
Finishing your studies in a university is not only a matter of studying and learning. To obtain
Input Format
There are multiple test cases in the input file. The first line contains two integer numbers **N** and **M**, representing the number of subjects in her degree and the number of correlation relations between pairs of subjects, respectively (**1** ****N,M ). The subjects are numbered from **1** to **N**. Each of the following **M** lines contains two integer numbers **A** and **B**, indicating that subject **A** is a correlation subject for subject **B** (**1** ****A, B** ****N** with **A ≠ B**). This means that subject **A** must be registered in the electronic system before subject **B** can be registered. There are no repeated or cyclic correlation relations in the input. The last line contains **N** integer numbers **P $ _{1} $ , P $ _{2} $ , ..., P $ _{N} $** , representing the subjects in the order Gabina will pass them (**1** ****P $ _{i} $** ****N** for **i = 1, ..., N**, with **P $ _{i} $ ≠ P $ _{j} $** for **i ≠ j**).************
Output Format
For each test case, print **N** lines, each with a single integer number. The number printed in the **i**-th line represents the number of subjects registered in the electronic system immediately after Gabina passes the **i**-th subject for her degree in the order giver in the input.