public static void main(String[] args) {
String rst="";
List<String> list=new ArrayList<String>();
List<String> lists=new ArrayList<String>();
Scanner scanner=new Scanner(System.in);
String nextLine=scanner.nextLine();
while (nextLine != null && !nextLine.equals("")) {
list.add(nextLine);
nextLine = scanner.nextLine();
}

if(list.size()<2){
System.exit(0);
}else if(list.size()==2)
{
System.out.println(list.get(1));
}else{
int count=Integer.valueOf(list.get(0));
String tmp="";
int ma[]=new int[list.size()-1];
int maxcount=0;
for(int i=1;i<list.size();i++){
String str=list.get(i);
String a[]=str.split(",");
Double len=Math.ceil((double)a.length/count);
ma[i-1]=len.intValue();
}
maxcount=ma[0];
for(int x =1;x<ma.length;x++){
if(ma[0]<ma[x]){
maxcount=ma[x];
}
}
list.remove(0);
while(maxcount!=0&&list.size()>0){
maxcount--;
lists=new ArrayList<String>();
for(int i=0;i<list.size();i++){
String str=list.get(i);
String a[]=str.split(",");
if(a.length>count){
tmp="";
for(int j=0;j<count;j++){
rst+=a[j]+",";
}
for(int j=count;j<a.length;j++){
tmp+=a[j]+",";
}
lists.add(tmp);
}else{
for(int j=0;j<a.length;j++){
rst+=a[j]+",";
}
}
}
list=lists;
}
System.out.println(rst.substring(0,rst.length()-1));
}

}