Consider a partially ordered set (poset, for short) (A,⊆), where A is a set and ⊆ a partial order.
An Hasse Diagram is a very convenient and compact graphical representation of a partially ordered set displayed via the cover relation of the poset. In a few words, the cover relation of a relation R is R minus the transitivity and the reflexivity.
Let us explain now how to draw a Hasse Diagram. Each node of the diagram is an element of the poset, and if two elements x and y are connected by a line then x ⊆ y or y ⊆ x .
The position of the elements and the connections are drawn respecting the following rules:
If x ⊆ y in the poset, then the point corresponding to x appears below the point corresponding to y.
The transitivity of the poset is graphically omitted, that is, if x ⊆ y and y ⊆ z, then, by transitivity of the partial order ⊆, x ⊆ z. In this case the connection x-z is omitted.
Along the same lines, the reflexivity is grafically omitted. In other words, for all x in the graph, the connection x-x is removed.
⊆
Figure 1. Hasse Diagram representation of the Poset(S={{1,2,3,5}, {2,3}, {5}, {3}, {1,3}, {1,5}}, ⊆)
Problem
Given a set Q of naturals such that |Q|=P. Consider a set S of N subsets of Q, that is, S ⊆ P(Q) and |S| = N. (S, ⊆) is then a partially ordered set. Each element K of S is a set on its own, with a maximum of P elements. The elements of K are positive and are increasingly ordered.
Given such a poset, your goal is to compute all the possible paths in its Hasse diagram from the highest elements to the lowest ones.
Constraints
Q and therefore the elements of S only contain values that fit a 16 bits representation.
0< N< 100
0< P≤ 100
Input
The first line of the input contains one positive integer number N, which is the number of elements of S. The following N lines contain the elements of S, one for each line. In each integer sequence, the elements are separated by a single space.
Output
Each line of the output file has the nodes of a path, of the Hasse Diagram, separated by ->. The paths must be lexicographically ordered. Observe Figure 1 and the sample output.