#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fstream.h>



int main()
{
FILE *finput;
FILE *foutput;
int count_open=0;
int count_close=0;
char slovo;
int count[2];
int chislo=0;
int i=0, error=0;

finput=fopen ("input.txt", "r");

do
{
fread (&slovo, sizeof(slovo), 1, finput);
switch (slovo)
{
case ('{'):
	count_open++;
	break;
case ('}'):
	{
	if (count_open>chislo)
		chislo=count_open-1;
	count_open--;
	break;
	}
case (','): break;
default:
if (error<2)
{
	 if (i<1)
	 {
	 i++;
	 if (chislo>0)
		count[0]=chislo;
	 if (chislo==0)
		count[0]=0;
	 chislo=0;
	 error++;
         count_open=0;
	 }
	 else
	 {
	 i=i+5;
	 if (chislo>0)
		count[1]=chislo;
	 if (chislo==0)
		count[1]=0;
	 error++;
	 }
	 break;
}
}

}while ((!feof(finput))&&(i<2));
fclose (finput);

chislo=count[0]+count[1];


std::ofstream myfile;
myfile.open ("output.txt");

int n=3;
std:: vector<std::string>bff;
bff.resize(0);
std::string result="";
for (i=0; i<n+1; i++)
{
	std:: string temp="";
	for (int j=0; j<bff.size(); j++)
		{
		temp+=bff[j];
		if (j!=bff.size()-1)
			temp+=",";
		}
		result+="{"+temp+"}";
		bff.push_back(result);

		if (i!=n)
			result+=",";
		}
		if (bff.size())
			result=bff[bff.size()-1];
		result="{"+result+"}";
		myfile<<result<<std.endl;
                myfile.close();


return 0;
}