Music Program

Time limit1sMemory limit128 MB

Problem

The producer of a music program must combine several partial running orders prepared by assistant producers into one complete order of singers.

Each assistant producer lists only the singers they are responsible for, in the relative order those singers must appear. A singer may appear in more than one list. The complete order must satisfy every listed relative order at the same time.

Given all partial orders, write a program that outputs one valid complete appearance order, or reports that no such order exists.

Input

The first line contains N, the number of singers, and M, the number of assistant producers. Singers are numbered from 1 through N.

Each of the next M lines describes one assistant producer's order. The first integer K is the number of singers in that list, followed by K singer numbers in the required order.

N is an integer between 1 and 1,000 inclusive, and M is an integer between 1 and 100 inclusive.

Output

If a complete order is possible, output N lines, each containing one singer number in order. If more than one answer is possible, any one of them may be printed.

If no complete order can satisfy all partial orders, print 0 on the first line.