#P1830. Bombing Analysis on Key Points

    ID: 15113 Type: Default 1000ms 256MiB

Bombing Analysis on Key Points

Bombing Analysis on Key Points

After a series of bombings, there are $y$ key points. The commander wants to know whether each point has been bombed. If a key point has been bombed, report how many times and in which round the last bombing occurred. If a key point was never bombed, output 0 0.

Input consists of an integer y denoting the number of key points and an integer n representing the number of bombing rounds. Each of the following n lines starts with an integer m indicating the number of bomb events in that round, followed by m integers denoting the key point indices (1-indexed) that were bombed. For each key point, output two numbers on a new line: the total number of bombings it received and the round number during which it was last bombed.

All mathematical formulas must be in LaTeX format, for example $$y$$.

inputFormat

The first line contains two integers y and n separated by a space, where y is the number of key points and n is the number of bombing rounds. The next n lines each begin with an integer m (the number of bombings in that round) followed by m integers representing the indices of key points that were bombed in that round. It is guaranteed that the indices are between 1 and y.

outputFormat

Output y lines. The i-th line should contain two integers separated by a space: the total number of times key point i was bombed and the round number when the last bomb dropped on key point i. If the key point was never bombed, output 0 0.

sample

3 2
1 2
2 1 2
1 2

2 2 0 0