Problem: Little Vasya likes very much to play with sets consisting of positive integers. To make the game more interesting, Vasya chose n non-empty sets in such a way, that no two of them have common elements.

One day he wanted to show his friends just how interesting playing with numbers is. For that he wrote out all possible unions of two different sets on n·(n - 1) / 2 pieces of paper. Then he shuffled the pieces of paper. He had written out the numbers in the unions in an arbitrary order.

For example, if n = 4, and the actual sets have the following form {1, 3}, {5}, {2, 4}, {7}, then the number of set pairs equals to six. The six pieces of paper can contain the following numbers: 

  * 2, 7, 4. 
  * 1, 7, 3; 
  * 5, 4, 2; 
  * 1, 3, 5; 
  * 3, 1, 2, 4; 
  * 5, 7. 



Then Vasya showed the pieces of paper to his friends, but kept the n sets secret from them. His friends managed to calculate which sets Vasya had thought of in the first place. And how about you, can you restore the sets by the given pieces of paper?

Input

The first input file line contains a number n (2 ≤ n ≤ 200), n is the number of sets at Vasya's disposal. Then follow sets of numbers from the pieces of paper written on n·(n - 1) / 2 lines. Each set starts with the number ki (2 ≤ ki ≤ 200), which is the number of numbers written of the i-th piece of paper, and then follow ki numbers aij (1 ≤ aij ≤ 200). All the numbers on the lines are separated by exactly one space. It is guaranteed that the input data is constructed according to the above given rules from n non-intersecting sets.

Output

Print on n lines Vasya's sets' description. The first number on the line shows how many numbers the current set has. Then the set should be recorded by listing its elements. Separate the numbers by spaces. Each number and each set should be printed exactly once. Print the sets and the numbers in the sets in any order. If there are several answers to that problem, print any of them.

It is guaranteed that there is a solution.

Examples

Input

4
3 2 7 4
3 1 7 3
3 5 4 2
3 1 3 5
4 3 1 2 4
2 5 7


Output

1 7 
2 2 4 
2 1 3 
1 5 


Input

4
5 6 7 8 9 100
4 7 8 9 1
4 7 8 9 2
3 1 6 100
3 2 6 100
2 1 2


Output

3 7 8 9 
2 6 100 
1 1 
1 2 


Input

3
2 1 2
2 1 3
2 2 3


Output

1 1 
1 2 
1 3 

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;


public class Task84BCodeForces {
	
	int n;
	ArrayList<Card> cards = new ArrayList<Card>();
	ArrayList<ArrayList<Integer>> sets = new ArrayList<ArrayList<Integer>>();
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Task84BCodeForces task = new Task84BCodeForces();
		
		task.getData();
		task.getSolution();
		//task.testLCS();
	}
	
	public void getData() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		n = Integer.parseInt(str);
	 
	
	    String[] data;
		for(int i= 0; i< n*(n-1)/2;i++){
			str = br.readLine();
			data = str.split("\\s");
			int k = Integer.parseInt(data[0]);
			ArrayList<Integer> a = new ArrayList<Integer>();
			for(int j=0;j<k;j++){
				a.add(Integer.parseInt(data[j+1]));
			}
			cards.add(new Card(a));
			
		}
		
	}
	
	public void getSolution(){
		//search for the shortest sequence
		Collections.sort(cards);
		Card c = cards.remove(0);
//		loop:for(int i=1;i<c.getSize();i++){
//			//get i-elements subSequence
//			ArrayList<ArrayList<Integer>> Hypoteses = c.getSubSequence(i);
//			for(ArrayList<Integer> h:Hypoteses){
//			if(checkHypotese(h)){
//				break loop;
//			}
//			}
//		}
		//find first sequence
		if(cards.size()==0){
			System.out.println("1 "+ c.values.remove(0));
			StringBuffer str = new StringBuffer("");
			str.append(c.getSize());
			for(Integer i:c.values){
				str.append(" " + i);
			}
			System.out.println(str.toString());
		}else{
		ArrayList<Integer> LCS = new ArrayList<Integer>();
		for(int i =0;i<cards.size();i++){
			LCS = (ArrayList<Integer>) AllCommonObjects(c.getValues(), cards.get(i).getValues());
			if(LCS.size()>0){
				break;
			}
		}
		checkHypotese(LCS);
		
		}
	}
	
	public boolean checkHypotese(ArrayList<Integer> firstHypotese){
		ArrayList<ArrayList<Integer>> sets = new ArrayList<ArrayList<Integer>>();
		ArrayList<Card> cardsClone = (ArrayList<Card>) cards.clone();
		Collections.sort(firstHypotese);
		sets.add(firstHypotese);
		while(sets.size()<n){
			int sizeBefore = sets.size();
			for(int j=0;j<sets.size();j++){
				for(int i=0;i<cardsClone.size();i++){
					if(cardsClone.get(i).contain(sets.get(j))){
						ArrayList<Integer> temp = cardsClone.get(i).minusMassive(sets.get(j));
						Collections.sort(temp);
						if(!sets.contains(temp)){
							sets.add(temp);
						}
						if(sets.size()==n){
							break;
						}
						cardsClone.remove(cardsClone.get(i--));
					}
				}
			}
			if(sets.size()==sizeBefore){
				return false;
			}
		}
		Collections.sort(sets, new Comp());
		for(ArrayList<Integer> arr:sets){
			StringBuffer str = new StringBuffer("");
			str.append(arr.size()+" ");
			for(Integer i: arr){
				str.append(i+" ");
			}
			System.out.println(str.toString());
		}
		//System.out.println(str.toString());
		return true;
	}
	
	public void testLCS(){
		String str = "15 70 93 49 78 184 140 82 26 152 134 13 90 104 52 139";
		String str2 = "12 93 140 90 158 134 3 150 190 152 52 75 95";
		String[] data = str.split("\\s");
		int k = Integer.parseInt(data[0]);
		int[] a1 = new int[k];
		for(int j=0;j<k;j++){
			a1[j] = (Integer.parseInt(data[j+1]));
		}
		data = str2.split("\\s");
		k = Integer.parseInt(data[0]);
		int[] a2 = new int[k];
		for(int j=0;j<k;j++){
			a2[j] = (Integer.parseInt(data[j+1]));
		}
		ArrayList<Integer> lcs = (ArrayList<Integer>) AllCommonObjects(a1, a2);
		for(Integer i:lcs){
			System.out.println(i);
		}
		
	}
	
	public  ArrayList<Integer> AllCommonObjects(int[] s1,int[] s2){
		ArrayList<Integer> commonObjects = new ArrayList<Integer>();
		loop:for(int i=0;i<s1.length;i++){
			for(int j=0;j<s2.length;j++){
				if(s1[i]==s2[j]){
					
					commonObjects.add(s1[i]);
					continue loop;
				}
			}
		}
		return commonObjects;
	}
	
	public static <E> List<E> LongestCommonSubsequence(E[] s1, E[] s2)
	{
	        int[][] num = new int[s1.length+1][s2.length+1];  //2D array, initialized to 0
	 
	        //Actual algorithm
	        for (int i = 1; i <= s1.length; i++)
	                for (int j = 1; j <= s2.length; j++)
	                        if (s1[i-1].equals(s2[j-1]))
	                                num[i][j] = 1 + num[i-1][j-1];
	                        else
	                                num[i][j] = Math.max(num[i-1][j], num[i][j-1]);
	 
	        System.out.println("length of LCS = " + num[s1.length][s2.length]);
	 
	        int s1position = s1.length, s2position = s2.length;
	        List<E> result = new ArrayList<E>();
	 
	        while (s1position != 0 && s2position != 0)
	        {
	                if (s1[s1position - 1].equals(s2[s2position - 1]))
	                {
	                        result.add(s1[s1position - 1]);
	                        s1position--;
	                        s2position--;
	                }
	                else if (num[s1position][s2position - 1] >= num[s1position - 1][s2position])
	                {
	                        s2position--;
	                }
	                else
	                {
	                        s1position--;
	                }
	        }
	        Collections.reverse(result);
	        return result;
	}
	
	public class Card implements Comparable<Card>{
		ArrayList<Integer> values;
		
		public Card(ArrayList<Integer> i){
			values = i;
		}
		public int getSize(){
			return values.size();
			
		}
		public ArrayList<Integer> minusMassive(ArrayList<Integer> a){
			ArrayList<Integer> result = new ArrayList<Integer>();
			for(Integer i:values){
				if(!a.contains(i)){
					result.add(i);
				}
			}
			return result;
		}
		
		public int[] getValues(){
			int[] v = new int[values.size()];
			for(int i=0;i<values.size();i++){
				v[i]=values.get(i);
			}
			return v;
		}
		@Override
		public int compareTo(Card c) {
			// TODO Auto-generated method stub
			return this.values.size()-c.values.size();
		}
		
		public ArrayList<ArrayList<Integer>> getSubSequence(int lenght){
			ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
			if(lenght == 1){
				for(Integer aTemp:values){
					ArrayList<Integer> array = new ArrayList<Integer>();
					array.add(aTemp);
					a.add(array);
				}
				return a;
			}else{
				ArrayList<ArrayList<Integer>> aTemp = getSubSequence(lenght-1);
				for(ArrayList<Integer> arr:aTemp){
					for(Integer i:values){
						if(!arr.contains(i)){
							ArrayList<Integer> arr2 = (ArrayList<Integer>) arr.clone();
							arr2.add(i);
							a.add(arr2);
							
						}
					}
				}
				return a;
			}
			
		}
		
		
		public boolean contain(ArrayList<Integer> a){
			boolean flag = true;
			for(Integer i:a){
				if(!values.contains(i)){
					flag = false;
				}
			}
			return flag;
		}
		
		public String toString(){
			StringBuffer str = new StringBuffer("");
			
				for(Integer i: values){
					str.append(i+" ");
				}
			return str.toString();
			
		}
		
		
	}
	
	public class Comp implements Comparator<ArrayList<Integer>>{

		@Override
		public int compare(ArrayList<Integer> arg0, ArrayList<Integer> arg1) {
			// TODO Auto-generated method stub
			return arg0.size()-arg1.size();
		}

		
		
	}

}