import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class freq_count
{
	public static void main(String args[])
	{
		try
		{
			
			FileOutputStream fo=new FileOutputStream("freq_counts.txt");
			PrintStream ds=new PrintStream(fo);
			//FileInputStream f3=new FileInputStream("param.txt");
			//DataInputStream bf3=new DataInputStream(f3);
			//ArrayList<String> param=new ArrayList<String>();
			//while(bf3.available()>0)
			//{
				//String str=bf3.readLine();
				//str=str.trim();
				//param.add(str); //adding to the parameters array list
			//}
			for(int i=8;i<=762;i++)
			{
			int counter=0;
			FileInputStream f=new FileInputStream("edges.txt");
			DataInputStream bf=new DataInputStream(f);
			//ds.print("Concepts learned for "+param.get(i-8)+" are:");
			ds.print(i+":");
			
			while(bf.available()>0)
			{
				String str=bf.readLine();
				//System.out.println("hi");
			
				StringTokenizer sToken=new StringTokenizer(str,",");
				System.out.println(sToken.nextToken());
				
				Integer ref=Integer.parseInt(sToken.nextToken().trim());
				Integer str1=Integer.parseInt(sToken.nextToken().trim());
				//sToken.nextToken();
			    Integer str2=Integer.parseInt(sToken.nextToken().trim());
				
				System.out.println(ref+" "+str1+" "+str2);
					if((i==str1.intValue()))
					{
						//counter++;
						if(str2.intValue()!=7)
						{
							//ds.print(param.get(str2.intValue()-8)+",");
							ds.print((str2.intValue()-8)+",");
						}
						
					}
				
				
			}
			ds.println("");
			//ds.println(i+" has "+counter+" links");
			}
		}catch(Exception e)
		{
			System.err.println(e);
		}
	}
}