QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#3635. Aromatic Adventure

統計

Mr. Malnar enjoys walking, and therefore he is interested in a walk through the fragrant city gardens. We can imagine the city gardens as a graph where the gardens are labeled with numbers from $1$ to $n$. There are exactly $m$ undirected unique edges between them. We also know that the garden labeled with the number $i$ has an aromaticity coefficient $A_i$.

It is well known to everyone that for a walk to be adventurous, the aromaticity must have its ups and downs, i.e., if we denote the gardens visited in the walk as $v_1, v_2, \dots, v_k$ (which are not necessarily distinct), it must hold that $A_{v_1} < A_{v_2} > A_{v_3} < A_{v_4} \dots$

Now, Mr. Malnar is interested in which gardens he can reach by an adventurous walk starting from garden $1$ (it is possible that Mr. Malnar's walk ends immediately in that garden).

Input

The first line contains the natural numbers $n$ ($1 \le n \le 3 \cdot 10^5$) and $m$ ($1 \le m \le 3 \cdot 10^5$) from the problem description.

The next line contains $n$ numbers, where the $i$-th number is $A_i$ ($1 \le A_i \le 10^9$).

In each of the next $m$ lines, there are two numbers $u_i$ and $v_i$ ($1 \le u_i, v_i \le n, v_i \neq u_i$) which indicate that gardens $u_i$ and $v_i$ are connected by an edge.

Output

In the first line, you need to print the number $k$, the number of gardens Mr. Malnar can reach.

In the next line, you need to print $k$ numbers in ascending order, the labels of the gardens Mr. Malnar can reach.

Examples

Input 1

5 7
3 5 3 1 3
2 1
4 1
3 1
2 3
5 3
4 3
4 5

Output 1

3
1 2 3

Input 2

6 6
4 6 3 6 6 10
4 6
3 1
4 2
2 1
5 1
4 3

Output 2

3
1 2 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.