Let's define an "expression" as a set composed only by number and brackets () [].
This is an expression: ( 18 4 [ 6 7 ( 4 ) 2 ] 6 8 )
Every expression starts with "(" and ends with ")".
There are N espressions in the input file, each is codified by M integers (N and M both aren't greater than 1000). Brackets are codified by negative integers. See this table:
( -1
) -2
[ -3
] -4
You can apply 2 basic operations to an expression to transform it into another:
1) You can permute the elements inside ()
2) You can reverse the elements inside []
By "element" we mean: a single number, or, an internal expression (see definition of expression, above).
For example, the above expression could be transformed into ( 8 [ 2 ( 4 ) 7 6 ] 18 6 4 ).
Two expressions A and B are equivalent only if you can obtain B starting from A, and vice-versa.
Your job is to classify the given N expression in K groups of equivalent expressions (K <= N).
INPUT:
First line contains N and M
N expressions follows (each is formed by M integers)
OUTPUT:
First line contains K (number of groups)
Follows K lines, each composed by Q+1 integers (where Q is the size of that group). These integers are respectively: Q, and the components of the group. See the sample output for clarity.
SAMPLE INPUT:
3 14
-1 18 4 -3 6 7 -1 4 -2 2 -4 6 8 -2
-1 8 -3 2 -1 4 -2 7 6 -4 18 6 3 -2-1 8 -3 2 -1 4 -2 7 6 -4 18 6 4 -2
SAMPLE OUTPUT:
2
2 1 3
1 2