cho.sh
Notes
Loading...

Sequence Restoration

Time limit

2s

Memory limit

128 MB

Problem

A sequence of length N has exactly N-M+1 contiguous subsequences of length M. You are given all of those contiguous subsequences, in arbitrary order. Restore any original sequence that could have produced them.

Only consecutive elements count as a subsequence in this problem. For example, {1 2} is a contiguous subsequence of {1 2 3} and of {3 1 2}, but it is not a contiguous subsequence of {1 3 2}.

Input

The first line contains two integers N and M, where 2 ≤ N ≤ 1,000 and 2 ≤ M ≤ N.

Each of the next N-M+1 lines contains one sequence of length M. The absolute value of every number in these sequences is at most 1,000,000,000.

Output

Print the restored sequence of length N on one line, with spaces between adjacent numbers. If there are multiple valid answers, print any one of them. Inputs that cannot be restored are not given.