Mall

상점마다 파는 상품 목록이 주어질 때, 모든 상점을 한 번씩 방문하는 순서와 각 상품을 살 상점을 정하되, 이미 구매한 상품을 파는 상점을 나중에 방문하지 않도록 해야 한다.

어려움8그래프위상 정렬그리디구현아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

Byton has been sent by his parents to a nearby shopping mall to buy mm products from the list, numbered 11 through mm. As he loves shopping, he plans to visit every shop in the mall, each of them exactly once. Byton is going to visit the shops in some order and in some of them, he will buy some products from the list that he has not bought yet.

As you can guess, some products may be available in multiple different shops. Unfortunately, Byton is a bit paranoid -- he fears random security checks very much. Therefore, he would like to avoid an awkward situation in which he enters a shop that sells a product that he has already purchased somewhere else.

Can you find a strategy of visiting all the shops and buying products, which will allow Byton to avoid awkward situations with security guards?

입력

The first line of the input contains two integers n,mn, m (1n,m10001 \le n, m \le 1000) -- the number of shops in the mall and the number of products Byton needs to buy, respectively. The next nn lines describe shops in the mall; the ii-th of them describes the ii-th shop. Each description begins with a number k_ik\_i (1k_im1\leq k\_i\leq m) denoting the number of products of Byton's interest available in the ii-th shop. Then, k_ik\_i integers, each between 11 and mm, follow in ascending order. Each of them denotes a product from Byton's list.

출력

If there does not exists a correct strategy of shopping, you should output a single word NO. Otherwise, the first line of the input should contain the word YES. The second line of the output should contain nn distinct integers ranging from 11 to nn -- the order of shops visited by Byton. The last, third line should contain mm integers ranging from 11 to nn; the ii-th of them indicates the shop in which Byton should buy the product ii. If there are multiple solutions, output any of them.

힌트

First, Byton should go to shop 11, not buying anything. Then, he should go to shop 22 and buy the products 22 and 44. Next, he can buy product 33 in shop 33 and finally buy product 11 in shop 44.