This page is still under construction.

Parts of this page are still being built. What you see may change.

Mall

Time limit1sMemory limit256 MB

Summary
Assign each product to a shop that sells it, and order the shops so that no shop is entered after a product it sells was already bought elsewhere.
Level

Medium7 of 10

Topics
Graph, Greedy, Topological sort, Implementation
Solved
No attempts yet

Problem

Byton's parents have sent him to a nearby shopping mall to buy the mm products on the list, numbered 11 through mm. He loves shopping, so he plans to visit every shop in the mall, each of them exactly once. Byton will 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?

Input

The first line of the input contains two integers n,mn, m (1≤n,m≤10001 \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 kik_i (1≤ki≤m1\leq k_i\leq m) denoting the number of products of Byton's interest available in the ii-th shop. Then, kik_i integers, each between 11 and mm, follow in ascending order. Each of them denotes a product from Byton's list.

Output

If there does not exist a correct strategy of shopping, you should output a single word NO. Otherwise, the first line of the output 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.

Hint

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.

Examples1

  1. Example 1

    Input
    4 4
    1 2
    2 2 4
    2 1 3
    1 1
    
    Expected output
    YES
    1 2 3 4
    4 2 3 2