//	This source and text sequencing method apply to GNU General Public License. 
//			Copyright (C) 2003  Jasenko Dzinleski 

//	This source applies to the GNU General Public License as
//	published by the Free Software Foundation 
//	and can not be used, copied, sold, redistributed or 
//	used in any other way but only by written permission by Jasenko Dzinleski . 
//	Copyright (C) from 2003 - 2014 and later by Jasenko Dzinleski 

//	This program is distributed in the hope that it will be useful, but
//	WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//	General Public License for more details. 

//	You should have received a copy of the GNU General Public License along
//	with this program; if not, write to the Free Software Foundation, Inc.,
//	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

//
//		text sequencing
//		written by Dzinleski Jasenko  2003 , 2014 , October 2016
//


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

FILE		*f1,*f2,*f3,*f11;

char		infn[256]="fasta__.txt";
//char		infn[256]="War_and_Peace_NT.txt";

char		out1fn[256]="out1.txt";
char		out2fn[256]="out2.txt";
char		out3fn[256]="out3.txt";
char		out4fn[256]="out4.txt";

int 		ba2b[256][256][256][2];	int ba2bi=0;
int 		bab[256][2][50000];	int babi=0;
int 		bab_[256][50000];	int babi_=0;

char		ca[3*8*1024];		int cai=0;

long		v[10][10];
char		vc[10][10][10];

//

char		csv[256];		int csvi=0;

char		cv[256];int cvi=0;
char		nl[256];int nli=0;

//
char		sv1_[256];
char		sv2_[256];
char		sv3_[256];
char		sv4_[256];
char		sv5_[256];
char		sv6_[256];
char		sv7_[256];
char		sv8_[256];

int		c1,c2,c3,c4,c5,c6,c7,c8,c9;
int		c1_,c2_,c3_,c4_,c5_,c6_,c7_,c8_,c9_;
//
int		j1_,n1_,c_1,c_1_,csv1_[256];
int		na[8][2];
int p_1(char sv1_[256])
{
	int i;
	if(strlen(sv1_)>1)
	{

		n1_=0;j1_=0;for(i=0;i<256;++i){csv1_[i]=-1;}
		for(i=0;i<strlen(sv1_);)
		{
			if(sv1_[i]!='_'){csv1_[j1_]=0;++j1_;++n1_;++i;}else{csv1_[j1_]=1;++i;while(sv1_[i]=='_'){++csv1_[j1_];++i;}++j1_;}
		}
		//for(i=0;i<j1;++i){printf("%d",csv1_[i]);}printf("\n");
	}else{return(-1);}
	return(1);
}

int p_2(char sv1_[256],int j1_,int n1_,int csv1_[256])
{
int i,l,n,m,k;
	c_1=0;c_1_=0;
	for(k=0;k<cai;++k)
	{
		m=0;l=0;i=0;
		while(l<j1_)
		{
			if(csv1_[l]){i+=csv1_[l];--i;}else{if(sv1_[i]!=ca[i+k]){break;}else{/*printf("%c",sv1[i]);*/if(m==0){n=k;}++m;}}
			++i;++l;
		}
		if(m==n1_){if(n<cai){++c_1;}else{++c_1_;}}
	}
	return(0);	
}

int main(int argc,char *argv[])
{

int	a,b,c,d,e;
int	i,j,k,l,m,n;
int	b1_,b2_,b3_,b4_,b5_;
int	b1,b2,b3,b4;

	for(i=0;i<256;++i){
	for(j=0;j<256;++j){
	for(k=0;k<256;++k){
		ba2b[i][j][k][0]=-1;
	}}}ba2bi=0;

	for(i=0;i<256;++i){
	for(j=0;j<50000;++j){
		bab[i][0][j]=-1;
		bab[i][1][j]=0;
	}}babi=0;

	for(i=0;i<256;++i){
	for(j=0;j<50000;++j){
		bab_[i][j]=0;
	}}babi_=0;

	f1=fopen(infn,"rb");

	b1_=getc(f1);
	b2_=getc(f1);
	b3_=getc(f1);
	b4_=getc(f1);
	b5_=getc(f1);

	while(!feof(f1))
	{

	if(
	ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]==-1
	)
	{
	ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]=ba2bi;	
	if(bab[(b4_&0xff)][0][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]]==-1)
	{
	bab[(b4_&0xff)][0][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]]=babi;
	++bab_[(b5_&0xff)][babi];
	++babi;
	++bab[(b4_&0xff)][1][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]];
	}else{++bab[(b4_&0xff)][1][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]];++bab_[(b5_&0xff)][bab[(b4_&0xff)][0][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]]];}
	++ba2bi;
	ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][1]=1;
	}else{
	++ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][1];
	if(bab[(b4_&0xff)][0][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]]==-1)
	{
	bab[(b4_&0xff)][0][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]]=babi;
	++bab_[(b5_&0xff)][babi];
	++babi;
	++bab[(b4_&0xff)][1][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]];
	}else{++bab[(b4_&0xff)][1][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]];++bab_[(b5_&0xff)][bab[(b4_&0xff)][0][ba2b[(b1_&0xff)][(b2_&0xff)][(b3_&0xff)][0]]];}
	}

	b1_=b2_;
	b2_=b3_;
	b3_=b4_;
	b4_=b5_;
	b5_=getc(f1);

	}
	fclose(f1);

	f2=fopen(out1fn,"wb");

	for(i=0;i<256;++i){
	if((char)i==' '||i==13||i==10){continue;}
	for(j=0;j<256;++j){
	if((char)j==' '||j==13||j==10){continue;}
	for(k=0;k<256;++k){
	if((char)k==' '||k==13||k==10){continue;}
	if(ba2b[i][j][k][0]!=-1)
	{
	fprintf(f2,"%d\t%c%c%c\t",ba2b[i][j][k][1],i,j,k);
	for(l=0;l<256;++l){
	if((char)l==' '||l==13||l==10){continue;}
	if(bab[l][1][ba2b[i][j][k][0]]>=1){fprintf(f2,"%c\t%d\t",l,bab[l][1][ba2b[i][j][k][0]]);}}fprintf(f2,"\n");
	}}}}

	fprintf(f2,"\n");
	fprintf(f2,"\n");

	for(i=0;i<256;++i){
	if((char)i==' '||i==13||i==10){continue;}
	for(j=0;j<256;++j){
	if((char)j==' '||j==13||j==10){continue;}
	for(k=0;k<256;++k){
	if((char)k==' '||k==13||k==10){continue;}
	if(ba2b[i][j][k][0]!=-1)
	{
	fprintf(f2,"%d\t%c%c%c\t",ba2b[i][j][k][1],i,j,k);
	for(l=0;l<256;++l){
	if((char)l==' '||l==13||l==10){continue;}
	if(bab[l][1][ba2b[i][j][k][0]]>=1)
	{
		fprintf(f2,"%c\t%d\t",l,bab[l][1][ba2b[i][j][k][0]]);
		for(m=0;m<256;++m){
		if((char)m==' '||m==13||m==10){continue;}
		if(bab_[m][bab[l][0][ba2b[i][j][k][0]]]>=1)
		{
		fprintf(f2,"%c%c\t%d\t",l,m,bab_[m][bab[l][0][ba2b[i][j][k][0]]]);
		}
		}
	}
	}
	fprintf(f2,"\n");
	}}}}
	fclose(f2);
	//printf("ok\n");

	f1=fopen(infn,"rb");

	for(i=0;i<256;++i){sv1_[i]='\0';}
	for(i=0;i<256;++i){sv2_[i]='\0';}
	for(i=0;i<256;++i){sv3_[i]='\0';}
	for(i=0;i<256;++i){sv4_[i]='\0';}
	for(i=0;i<256;++i){sv5_[i]='\0';}
	for(i=0;i<256;++i){sv6_[i]='\0';}
	for(i=0;i<256;++i){sv7_[i]='\0';}
	for(i=0;i<256;++i){sv8_[i]='\0';}

	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;
	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;
	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;

	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;
	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;
	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;

	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;
	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;
	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;

	while(!feof(f1))
	{

	b1_=getc(f1);while(((char)b1_==' '||b1_==13||b1_==10)){b1_=getc(f1);}ca[cai]=b1_;++cai;

	if(cai>=3*8*1024)
	{

	for(n=0;n<3*8*1024;++n)
	{

	m=0;
	for(i=0;i<256;++i){sv1_[i]='\0';}
	for(l=n;l<n+(3*8);l+=3)
	{

	//
	v[m][0]=ba2b[ca[l+0]][ca[l+1]][ca[l+2]][1];
	vc[m][0][0]=ca[l+0];
	vc[m][0][1]=ca[l+1];
	vc[m][0][2]=ca[l+2];

	//
	v[m][1]=-1;	
	for(i=0;i<256;++i)
	{
	if(ba2b[i][ca[l+1]][ca[l+2]][0]!=-1)
	{
	if(v[m][1]==-1)
	{
		v[m][1]=ba2b[i][ca[l+1]][ca[l+2]][1];
		vc[m][1][0]=i;
		vc[m][1][1]=ca[l+1];
		vc[m][1][2]=ca[l+2];
	}else{
		if(v[m][1]<ba2b[i][ca[l+1]][ca[l+2]][1])
		{
			v[m][1]=ba2b[i][ca[l+1]][ca[l+2]][1];
			vc[m][1][0]=i;
			vc[m][1][1]=ca[l+1];
			vc[m][1][2]=ca[l+2];
		}
	}
	}
	}
	//
	v[m][2]=-1;	
	for(i=0;i<256;++i)
	{
	if(ba2b[ca[l+0]][i][ca[l+2]][0]!=-1)
	{
	if(v[m][2]==-1)
	{
		v[m][2]=ba2b[ca[l+0]][i][ca[l+2]][1];
		vc[m][2][0]=ca[l+0];
		vc[m][2][1]=i;
		vc[m][2][2]=ca[l+2];
	}else{
		if(v[m][2]<ba2b[ca[l+0]][i][ca[l+2]][1])
		{
			v[m][2]=ba2b[ca[l+0]][i][ca[l+2]][1];
			vc[m][2][0]=ca[l+0];
			vc[m][2][1]=i;
			vc[m][2][2]=ca[l+2];
		}
	}
	}
	}
	//
	v[m][3]=-1;	
	for(i=0;i<256;++i)
	{
	if(ba2b[ca[l+0]][ca[l+1]][i][0]!=-1)
	{
	if(v[m][3]==-1)
	{
		v[m][3]=ba2b[ca[l+0]][ca[l+1]][i][1];
		vc[m][3][0]=ca[l+0];
		vc[m][3][1]=ca[l+1];
		vc[m][3][2]=i;
	}else{
		if(v[m][3]<ba2b[ca[l+0]][ca[l+1]][i][1])
		{
			v[m][3]=ba2b[ca[l+0]][ca[l+1]][i][1];
			vc[m][3][0]=ca[l+0];
			vc[m][3][1]=ca[l+1];
			vc[m][3][2]=i;
		}
	}
	}
	}
	//
	//if(v[m][0]!=-1&&v[m][1]!=-1&&v[m][2]!=-1&&v[m][3]!=-1){++m;}
	++m;
	if(m>=8)
	{

	i=0;
	/*	
	printf("%d-- |%c%c%c|\n",i,vc[i][0][0],vc[i][0][1],vc[i][0][2]);
	printf("%d-1 |%c%c%c|\n",i,vc[i][1][0],vc[i][1][1],vc[i][1][2]);
	printf("%d-1 |%c%c%c|\n",i,vc[i][2][0],vc[i][2][1],vc[i][2][2]);
	printf("%d-1 |%c%c%c|\n",i,vc[i][3][0],vc[i][3][1],vc[i][3][2]);
	*/
	if(v[i][1]>v[i][2]&&v[i][1]>v[i][3])
	{sv1_[i*3+0]='_';sv1_[i*3+1]=vc[i][1][1];sv1_[i*3+2]=vc[i][1][2];}
	if(v[i][2]>v[i][1]&&v[i][2]>v[i][3])
	{sv1_[i*3+1]='_';sv1_[i*3+0]=vc[i][2][0];sv1_[i*3+2]=vc[i][2][2];}
	if(v[i][3]>v[i][1]&&v[i][3]>v[i][2])
	{sv1_[i*3+2]='_';sv1_[i*3+0]=vc[i][2][0];sv1_[i*3+1]=vc[i][2][1];}

	++i;
	/*
	printf("%d-- |%c%c%c|\n",i,vc[i][0][0],vc[i][0][1],vc[i][0][2]);
	printf("%d-2 |%c%c%c|\n",i,vc[i][1][0],vc[i][1][1],vc[i][1][2]);
	printf("%d-2 |%c%c%c|\n",i,vc[i][2][0],vc[i][2][1],vc[i][2][2]);
	printf("%d-2 |%c%c%c|\n",i,vc[i][3][0],vc[i][3][1],vc[i][3][2]);
	*/
	if(v[i][1]>v[i][2]&&v[i][1]>v[i][3])
	{sv1_[i*3+0]='_';sv1_[i*3+1]=vc[i][1][1];sv1_[i*3+2]=vc[i][1][2];}
	if(v[i][2]>v[i][1]&&v[i][2]>v[i][3])
	{sv1_[i*3+1]='_';sv1_[i*3+0]=vc[i][2][0];sv1_[i*3+2]=vc[i][2][2];}
	if(v[i][3]>v[i][1]&&v[i][3]>v[i][2])
	{sv1_[i*3+2]='_';sv1_[i*3+0]=vc[i][2][0];sv1_[i*3+1]=vc[i][2][1];}

	++i;
	/*
	printf("%d-- |%c%c%c|\n",i,vc[i][0][0],vc[i][0][1],vc[i][0][2]);
	printf("%d-3 |%c%c%c|\n",i,vc[i][1][0],vc[i][1][1],vc[i][1][2]);
	printf("%d-3 |%c%c%c|\n",i,vc[i][2][0],vc[i][2][1],vc[i][2][2]);
	printf("%d-3 |%c%c%c|\n",i,vc[i][3][0],vc[i][3][1],vc[i][3][2]);
	*/
	if(v[i][1]>v[i][2]&&v[i][1]>v[i][3])
	{sv1_[i*3+0]='_';sv1_[i*3+1]=vc[i][1][1];sv1_[i*3+2]=vc[i][1][2];}
	if(v[i][2]>v[i][1]&&v[i][2]>v[i][3])
	{sv1_[i*3+1]='_';sv1_[i*3+0]=vc[i][2][0];sv1_[i*3+2]=vc[i][2][2];}
	if(v[i][3]>v[i][1]&&v[i][3]>v[i][2])
	{sv1_[i*3+2]='_';sv1_[i*3+0]=vc[i][2][0];sv1_[i*3+1]=vc[i][2][1];}
	
	m=0;
	}

	if(strlen(sv1_)==9)
	{
	if(strlen(sv1_)&&!strlen(sv2_))
	{
	for(i=0;i<256;++i){sv2_[i]=sv1_[i];}
	for(i=0;i<256;++i){sv1_[i]='\0';}
	//printf("sv2_ %s\n",sv2_);
	}
	if(strlen(sv1_)&&strlen(sv2_)&&!strlen(sv3_))
	{
	for(i=0;i<256;++i){sv3_[i]=sv1_[i];}
	for(i=0;i<256;++i){sv1_[i]='\0';}
	//printf("sv3_ %s\n",sv3_);
	}
	if(strlen(sv1_)&&strlen(sv2_)&&strlen(sv3_)&&!strlen(sv4_))
	{
	for(i=0;i<256;++i){sv4_[i]=sv1_[i];}
	for(i=0;i<256;++i){sv1_[i]='\0';}
	//printf("sv4_ %s\n",sv4_);
	}
	if(strlen(sv1_)&&strlen(sv2_)&&strlen(sv3_)&&strlen(sv4_)&&!strlen(sv5_))
	{
	for(i=0;i<256;++i){sv5_[i]=sv1_[i];}
	for(i=0;i<256;++i){sv1_[i]='\0';}
	//printf("sv4_ %s\n",sv5_);
	}
	if(strlen(sv1_)&&strlen(sv2_)&&strlen(sv3_)&&strlen(sv4_)&&strlen(sv5_)&&!strlen(sv6_))
	{
	for(i=0;i<256;++i){sv6_[i]=sv1_[i];}
	for(i=0;i<256;++i){sv1_[i]='\0';}
	//printf("sv4_ %s\n",sv6_);
	}
	if(strlen(sv1_)&&strlen(sv2_)&&strlen(sv3_)&&strlen(sv4_)&&strlen(sv5_)&&strlen(sv6_)&&!strlen(sv7_))
	{
	for(i=0;i<256;++i){sv7_[i]=sv1_[i];}
	for(i=0;i<256;++i){sv1_[i]='\0';}
	//printf("sv4_ %s\n",sv7_);
	}
	if(strlen(sv1_)&&strlen(sv2_)&&strlen(sv3_)&&strlen(sv4_)&&strlen(sv5_)&&strlen(sv6_)&&strlen(sv7_)&&!strlen(sv8_))
	{
	for(i=0;i<256;++i){sv8_[i]=sv1_[i];}
	for(i=0;i<256;++i){sv1_[i]='\0';}
	//printf("sv4_ %s\n",sv8_);
	}
	if(strlen(sv1_)&&strlen(sv2_)&&strlen(sv3_)&&strlen(sv4_)&&strlen(sv5_)&&strlen(sv6_)&&strlen(sv7_)&&strlen(sv8_))
	{

	int 	j1,n1,csv1[256];
	char 	sv1[256];
		
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv1_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c1_=c_1;
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv2_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c2_=c_1;
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv3_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c3_=c_1;
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv4_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c4_=c_1;
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv5_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c5_=c_1;
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv6_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c6_=c_1;
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv7_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c7_=c_1;
	//
	for(i=0;i<256;++i){sv1[i]='\0';}
	for(i=0;i<strlen(sv1_);++i){sv1[i]=sv8_[i];}
	i=p_1(sv1);n1=n1_;j1=j1_;for(i=0;i<256;++i){csv1[i]=csv1_[i];}
	i=p_2(sv1,j1,n1,csv1);c8_=c_1;
	//
	i=0;
	na[i][0]=c1_;na[i][1]=i+1;
	na[++i][0]=c2_;na[i][1]=i+1;
	na[++i][0]=c3_;na[i][1]=i+1;
	na[++i][0]=c4_;na[i][1]=i+1;
	na[++i][0]=c5_;na[i][1]=i+1;
	na[++i][0]=c6_;na[i][1]=i+1;
	na[++i][0]=c7_;na[i][1]=i+1;
	na[++i][0]=c8_;na[i][1]=i+1;
	for(i=0;i<8;++i){for(j=0;j<8;++j){if(na[i][0]>na[j][0]){k=na[i][0];na[i][0]=na[j][0];na[j][0]=k;k=na[i][1];na[i][1]=na[j][1];na[j][1]=k;}}}
	//for(k=0;k<8;++k){printf("!%d!%d!",na[k][0],na[k][1]);}
	for(k=0;k<8;++k)
	{
	if(na[k][1]==1){printf("%03d",c1_);}		
	if(na[k][1]==2){printf("%03d",c2_);}
	if(na[k][1]==3){printf("%03d",c3_);}
	if(na[k][1]==4){printf("%03d",c4_);}
	if(na[k][1]==5){printf("%03d",c5_);}
	if(na[k][1]==6){printf("%03d",c6_);}
	if(na[k][1]==7){printf("%03d",c7_);}
	if(na[k][1]==8){printf("%03d",c8_);}
	}
	printf("\t");
	for(k=0;k<8;++k)
	{
	if(na[k][1]==1){i=0;for(j=0;j<strlen(sv1_);++j){while(sv1_[j]!='_'&&j<strlen(sv1_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==2){i=0;for(j=0;j<strlen(sv2_);++j){while(sv2_[j]!='_'&&j<strlen(sv2_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==3){i=0;for(j=0;j<strlen(sv3_);++j){while(sv3_[j]!='_'&&j<strlen(sv3_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==4){i=0;for(j=0;j<strlen(sv4_);++j){while(sv4_[j]!='_'&&j<strlen(sv4_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==5){i=0;for(j=0;j<strlen(sv5_);++j){while(sv5_[j]!='_'&&j<strlen(sv5_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==6){i=0;for(j=0;j<strlen(sv6_);++j){while(sv6_[j]!='_'&&j<strlen(sv6_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==7){i=0;for(j=0;j<strlen(sv7_);++j){while(sv7_[j]!='_'&&j<strlen(sv7_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==8){i=0;for(j=0;j<strlen(sv8_);++j){while(sv8_[j]!='_'&&j<strlen(sv8_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	}
	printf("\t");
	for(k=0;k<8;++k)
	{
	if(na[k][1]==1){i=0;for(j=0;j<strlen(sv1_);++j){while(sv1_[j]=='_'&&j<strlen(sv1_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==2){i=0;for(j=0;j<strlen(sv2_);++j){while(sv2_[j]=='_'&&j<strlen(sv2_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==3){i=0;for(j=0;j<strlen(sv3_);++j){while(sv3_[j]=='_'&&j<strlen(sv3_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==4){i=0;for(j=0;j<strlen(sv4_);++j){while(sv4_[j]=='_'&&j<strlen(sv4_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==5){i=0;for(j=0;j<strlen(sv5_);++j){while(sv5_[j]=='_'&&j<strlen(sv5_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==6){i=0;for(j=0;j<strlen(sv6_);++j){while(sv6_[j]=='_'&&j<strlen(sv6_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==7){i=0;for(j=0;j<strlen(sv7_);++j){while(sv7_[j]=='_'&&j<strlen(sv7_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	if(na[k][1]==8){i=0;for(j=0;j<strlen(sv8_);++j){while(sv8_[j]=='_'&&j<strlen(sv8_)){++j;++i;}if(i){printf("%02d",i);i=0;}}}
	}
	printf("\t");
	//printf("%03d%03d%03d%03d%03d%03d%03d%03d\t",c1_,c2_,c3_,c4_,c5_,c6_,c7_,c8_);		
	for(k=0;k<8;++k)
	{
	if(na[k][1]==1){printf("%s\t",sv1_);}
	if(na[k][1]==2){printf("%s\t",sv2_);}
	if(na[k][1]==3){printf("%s\t",sv3_);}
	if(na[k][1]==4){printf("%s\t",sv4_);}
	if(na[k][1]==5){printf("%s\t",sv5_);}
	if(na[k][1]==6){printf("%s\t",sv6_);}
	if(na[k][1]==7){printf("%s\t",sv7_);}
	if(na[k][1]==8){printf("%s\t",sv8_);}
	}
	printf("\n");
	for(i=0;i<256;++i){sv1_[i]='\0';}
	for(i=0;i<256;++i){sv2_[i]='\0';}
	for(i=0;i<256;++i){sv3_[i]='\0';}
	for(i=0;i<256;++i){sv4_[i]='\0';}
	for(i=0;i<256;++i){sv5_[i]='\0';}	
	for(i=0;i<256;++i){sv6_[i]='\0';}	
	for(i=0;i<256;++i){sv7_[i]='\0';}	
	for(i=0;i<256;++i){sv8_[i]='\0';}		
	
	}
	}

	}
	}

	ca[0]=ca[cai-9];
	ca[1]=ca[cai-8];
	ca[2]=ca[cai-7];

	ca[3]=ca[cai-6];
	ca[4]=ca[cai-5];
	ca[5]=ca[cai-4];

	ca[6]=ca[cai-3];
	ca[7]=ca[cai-2];
	ca[8]=ca[cai-1];

	cai=8+1;

	}

	}
	fclose(f1);

	return(0);

}