CF1361A.Johnny and Contribution

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Today Johnny wants to increase his contribution. His plan assumes writing nn blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a reference has to cover different topics because otherwise, the readers can notice that they are split just for more contribution. Set of blogs and bidirectional references between some pairs of them is called blogs network.

There are nn different topics, numbered from 11 to nn sorted by Johnny's knowledge. The structure of the blogs network is already prepared. Now Johnny has to write the blogs in some order. He is lazy, so each time before writing a blog, he looks at it's already written neighbors (the blogs referenced to current one) and chooses the topic with the smallest number which is not covered by neighbors. It's easy to see that this strategy will always allow him to choose a topic because there are at most n1n - 1 neighbors.

For example, if already written neighbors of the current blog have topics number 11 , 33 , 11 , 55 , and 22 , Johnny will choose the topic number 44 for the current blog, because topics number 11 , 22 and 33 are already covered by neighbors and topic number 44 isn't covered.

As a good friend, you have done some research and predicted the best topic for each blog. Can you tell Johnny, in which order he has to write the blogs, so that his strategy produces the topic assignment chosen by you?

输入格式

The first line contains two integers nn (1n5105)(1 \leq n \leq 5 \cdot 10^5) and mm (0m5105)(0 \leq m \leq 5 \cdot 10^5) — the number of blogs and references, respectively.

Each of the following mm lines contains two integers aa and bb ( aba \neq b ; 1a,bn1 \leq a, b \leq n ), which mean that there is a reference between blogs aa and bb . It's guaranteed that the graph doesn't contain multiple edges.

The last line contains nn integers t1,t2,,tnt_1, t_2, \ldots, t_n , ii -th of them denotes desired topic number of the ii -th blog ( 1tin1 \le t_i \le n ).

输出格式

If the solution does not exist, then write 1-1 . Otherwise, output nn distinct integers p1,p2,,pnp_1, p_2, \ldots, p_n (1pin)(1 \leq p_i \leq n) , which describe the numbers of blogs in order which Johnny should write them. If there are multiple answers, print any.

输入输出样例

  • 输入#1

    3 3
    1 2
    2 3
    3 1
    2 1 3

    输出#1

    2 1 3
  • 输入#2

    3 3
    1 2
    2 3
    3 1
    1 1 1

    输出#2

    -1
  • 输入#3

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

    输出#3

    2 5 1 3 4

说明/提示

In the first example, Johnny starts with writing blog number 22 , there are no already written neighbors yet, so it receives the first topic. Later he writes blog number 11 , it has reference to the already written second blog, so it receives the second topic. In the end, he writes blog number 33 , it has references to blogs number 11 and 22 so it receives the third topic.

Second example: There does not exist any permutation fulfilling given conditions.

Third example: First Johnny writes blog 22 , it receives the topic 11 . Then he writes blog 55 , it receives the topic 11 too because it doesn't have reference to single already written blog 22 . Then he writes blog number 11 , it has reference to blog number 22 with topic 11 , so it receives the topic 22 . Then he writes blog number 33 which has reference to blog 22 , so it receives the topic 22 . Then he ends with writing blog number 44 which has reference to blog 55 and receives the topic 22 .

首页