//
//  main.cpp
//  hw
//
//  Created by ? ? on 12-12-16.
//  Copyright (c) 2012? ? ?. All rights reserved.
//

int main(int argc, const char * argv[])
{
    double rate;
    char gen1[500],gen2[500];
    cin>>rate>>gen1>>gen2;
    int len1=strlen(gen1),len2=strlen(gen2),S=0;
    if (len1!=len2) {
        cout<<"error"<<endl;
        return 0;
    }
    for (int i=0; i<len1; i++) {
        if ((gen2[i]!='A'&&gen2[i]!='T'&&gen2[i]!='C'&&gen2[i]!='G')||(gen1[i]!='A'&&gen1[i]!='T'&&gen1[i]!='C'&&gen1[i]!='G')) {
            cout<<"error"<<endl;
            return 0;
        }
        if (gen1[i]==gen2[i]) {
            S++;
        }
    }
    double R;
    R=(double)S/len1;
    if (R>=rate) {
        cout<<"yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"no"<<endl;
        return 0;
    }
   return 0;
}


int main()
{
	char s[2][501];
	double n;
	double sum=0,x,Len;
	int len,i,len2,j;
	scanf("%lf",&n);
	scanf("%s%s",s[0],s[1]);
	len=strlen(s[0]);
	len2=strlen(s[1]);
	if(len!=len2)
	{
		printf("error");
		return 0;
	}
	else
	{
		for(i=0;i<2;i++){
			for(j=0;j<len;j++){
				if(s[i][j]!='A'&&s[i][j]!='T'&&s[i][j]!='G'&&s[i][j]!='C')
				{
					printf("error");
					return 0;
				}
				else continue;
			}
		}
	}

	for(i=0;i<len;i++)
	{
		if(s[0][i]==s[1][i]) sum=sum+1;
	}
	Len=(double)len;
	x=sum/Len;
	if(x>=n)
	{
		printf("yes");
	}
	else
	{
		printf("no");
	}
	return 0;
}


int main()
{
	int len1,len2,i,x;
	double n,result=0,result1;
	char dna1[500];
	char dna2[500];
	scanf("%lf",&n);
	scanf("%s%s",dna1,dna2);
	len1=strlen(dna1);
	len2=strlen(dna2);
	if(len1!=len2)
	{
		printf("error");
		return 0;
	}
	if(len1==len2)
	{
		for(i=0;i<len1;i++)
		{
			if(((dna1[i]=='A')||(dna1[i]=='T')||(dna1[i]=='C')||(dna1[i]=='G'))&&((dna2[i]=='A')||(dna2[i]=='T')||(dna2[i]=='C')||(dna2[i]=='G')))
			{
				x=1;
			}
			else
			{
				x=0;
				break;
			}
		}
	}
	if(x==0)
	{
		printf("error");
		return 0;
	}
	if(x==1)
	{
	for(i=0;i<len1;i++)
	{
		if(dna1[i]!=dna2[i])
		{
			result++;
		}
	}
	result1=(double)1-(result/len1);
	if((result1)>n)
	{
		printf("yes");
	}
	if((result1)<=n)
	{
		printf("no");
	}
	}
	return 0;
}


int main()
{
	int i;
	int num=0;
	double alike,n;
	char jj1[500]={0};
	char jj2[500]={0};
	scanf("%lf",&n);
	scanf("%s",jj1);
	scanf("%s",jj2);
	int result1=strlen(jj1);
	int result2=strlen(jj2);
	if(result1!=result2){
		printf("error");

	    return 0;
}
	else{
		result2=result1;
		for(i=0;i<result1;i++){
			if(((jj1[i]=='A')||(jj1[i]=='G')||(jj1[i]=='C')||(jj1[i]=='T'))&&((jj2[i]=='A')||(jj2[i]=='G')||(jj2[i]=='C')||(jj2[i]=='T'))){
				if(jj1[i]==jj2[i]){
					num+=1;
				}
}

			else{
				printf("error");
return 0;

			}
		}
	}
		alike=1.0*num/result1;
		if(alike>=n)
		{	printf("yes");
		}
		else{
			printf("no");
		}

	return 0;
}


int main(){
    int i,n,m,result;
    double c,w;
    int a=0;
    scanf("%lf",&w);
    scanf("\n");
    char xlyi[501],xler[501];
    gets(xlyi);
    gets(xler);
    n=strlen(xlyi);
    m=strlen(xler);
    if(m!=n){
        result=0;
    }else{
    for(i=0;i<n;i++){
        if((xlyi[i]!='A'&&xlyi[i]!='G'&&xlyi[i]!='C'&&xlyi[i]!='T')||(xler[i]!='A'&&xler[i]!='G'&&xler[i]!='C'&&xler[i]!='T')){
            result=0;
        }else{
            result=1;
        }
      }
    }
    if(result==1){
    for(i=0;i<m;i++){
            if(xlyi[i]==xler[i]){
                a++;
            }
        }
    }
    c=1.00*a/n;
    if(result==0){
        printf("error");
    }else if(c>=w){
        printf("yes");
    }else if(c<w){
        printf("no");
    }
    return 0;
}


int main()
{
	double m;
	scanf("%lf",&m);
	char a[500],b[500];
	scanf("%s%s",a,b);
	int ci=0;
	int pan=0;
	int aa=strlen(a),bb=strlen(b);
	if(aa!=bb)
	{
		printf("error");
	}
	else
	{
		int i;
		for(i=0;i<aa;i++)
		{
			if((a[i]!='A'&&a[i]!='T'&&a[i]!='G'&&a[i]!='C')||(b[i]!='A'&&b[i]!='T'&&b[i]!='G'&&b[i]!='C'))
			{
				printf("error");
				pan=1;
				break;
			}
			else
				if(a[i]==b[i])
			{
				ci++;
			}
		}
	   double bi=(double)ci/aa;
	  if(pan==0)
	  {
	    if(bi>=m)
		{
		printf("yes");
		}
	    else
		{
		printf("no");
		}
	  }
	}

	return 0;
}


int main(){
	char a[1000],b[1000];
	double w;
	int count=0,lena,lenb;
	scanf("%lf",&w);
	cin>>a;
	cin>>b;
	lena=strlen(a);
	lenb=strlen(b);

	if(lena!=lenb)printf("error");
	else{
		int i,j,k=0;
		for(i=0;i<lena;i++){
		if(!((a[i]=='A'||a[i]=='C'||a[i]=='G'||a[i]=='T')&&(b[i]=='A'||b[i]=='G'||b[i]=='C'||b[i]=='T'))){
			printf("error");k=1;break;

		}
	}
		if(k==0){
			for(j=0;j<lena;j++){
				if(a[j]==b[j])count++;
			}
			double what;
			what=(double)count/lena;
				if(what>=w)printf("yes");
				else printf("no");
				}
			}
	return 0;
		}


int main(){
	int i,x,y,m=0;
	double n;
	char a[501],b[501];
	scanf("%lf\n",&n);
	gets(a);
	gets(b);
	x=strlen(a);
	y=strlen(b);
	if(x==y){
		for(i=0;i<x;i++){
			if(a[i]!='A'&&a[i]!='G'&&a[i]!='C'&&a[i]!='T'){
				printf("error");
				break;
			}else{
				if(b[i]!='A'&&b[i]!='G'&&b[i]!='C'&&b[i]!='T'){
					printf("error");
					break;
				}else{
					if(a[i]==b[i])
						m++;
			}}
			if(i==x-1){
				if(1.0*m/x>n){
					printf("yes");
				}else{
					printf("no");
		}}}
	}else{
		printf("error");
	}
	return 0;
}


int main()
{
	int i,m,n,x=0;
	double p,y;
	char a[500],b[500];
	scanf("%lf\n",&p);
	gets(a);
	gets(b);
	m=strlen(a);
	n=strlen(b);
	if(m!=n)
	{
		printf("error");
		return 0;
	}
	else
	{
		for(i=0;i<m;i++)
		{
			if(a[i]!='A'&&a[i]!='T'&&a[i]!='G'&&a[i]!='C'||b[i]!='A'&&b[i]!='T'&&b[i]!='G'&&b[i]!='C')
			{
				printf("error");
				return 0;
			}
			else
			{
				if(a[i]==b[i])
				{
					x++;
				}
			}
		}
		y=(double)x/m;
		if(y>p)
		{
			printf("yes");
		}
		else
		{
			printf("no");
		}
		return 0;
	}
}


int main(){
	double e;
	char zf[2][501],count=0,c,w=0;
    scanf("%lf%c",&e,&c);
	gets(zf[0]);
	gets(zf[1]);
    int a=strlen(zf[0]),b=strlen(zf[1]);
	if(a!=b){
		printf("error");
	}else{
		for(int m=0;m<a;m++){
			for(int o=0;o<2;o++){
				if(zf[o][m]!='A'&&zf[o][m]!='T'&&zf[o][m]!='G'&&zf[o][m]!='C'){
					w++;
				}
			}
		}
		if(w!=0){
			printf("error");
		}else{
		for(int i=0;i<a;i++){
			if(zf[0][i]==zf[1][i]){
				count++;
			}
		}
		if(1.0*count/a>e){
			printf("yes");
		}else{
			printf("no");
		}
		}
	}

    return 0;
}


main()
{
      double n;
      char a[600],b[600];
      scanf("%lf",&n);
      scanf("%s",a);
      scanf("%s",b);
      int len=strlen(a),time=0,i;
      if(strlen(a)!=strlen(b)) printf("error\n");
      else
      {
           for(i=0;i<len;i++)
           {
                   if((a[i]!='A'&&a[i]!='T'&&a[i]!='G'&&a[i]!='C')||(b[i]!='A'&&b[i]!='T'&&b[i]!='G'&&b[i]!='C')) break;
                   else if(a[i]==b[i]) time++;
           }
           if(i==len)
           {
                     if((double)time/(double)len>n) printf("yes\n");
                     else printf("no\n");
           }
           else printf("error\n");
      }
}


int main()
{
	int i,k,sum=0,flag=0;
	double m;
	char zifu1[501],zifu2[501];
	scanf("%lf",&m);
	scanf("\n");
	gets(zifu1);
	gets(zifu2);
	if(strlen(zifu1)==strlen(zifu2))
	{
		for(i=0;i<600;i++)
		{
			if(zifu1[i]=='\0')
			{
				break;
			}
			else if((zifu1[i]=='A'||zifu1[i]=='T'||zifu1[i]=='C'||zifu1[i]=='G')&&(zifu2[i]=='A'||zifu2[i]=='T'||zifu2[i]=='C'||zifu2[i]=='G'))
			{
				if(zifu1[i]==zifu2[i])
				{
					sum++;
				}
			}
			else
			{
				printf("error");
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			if(1.0*sum/strlen(zifu1)>m)
			{
				printf("yes");
			}
			else
			{
				printf("no");
			}
		}
	}
	else
	{
		printf("error");
	}
	return 0;
}


int main(){
	double n;
	scanf("%lf",&n);
	char zfc[500],sz[500];
	scanf("%s%s",zfc,sz);
	int a=strlen(zfc);
	int b=strlen(sz);
	int m;
    if(a!=b){printf("error");}
	else{
		m=a;
		int k=0;
		int y;
		for(y=0;y<m;y++){
			if(zfc[y]!='A'&&zfc[y]!='T'&&zfc[y]!='C'&&zfc[y]!='G'&&zfc[y]!='\0'){
				printf("error");
			k=1;
			break;}
			if(sz[y]!='A'&&sz[y]!='T'&&sz[y]!='C'&&sz[y]!='G'&&zfc[y]!='\0'){
				printf("error");
			k=1;
			break;}
		}
			if(k==0){

	int i,c=0;
	for(i=0;i<m;i++){
		if(zfc[i]==sz[i]){
			c++;
		}
	}
	double s=c*1.0/m;
	if(s>n){printf("yes");}
	else{printf("no");}
	}
		}
	return 0;
}


int main(){
	int n,k=0,i;
	double e;
	char str[501],s[501];
	scanf("%lf",&e);
	scanf("%s %s",str, s);
	for(i=0;i<strlen(str);i++){
		if(str[i]!='A'&&str[i]!='T'&&str[i]!='G'&&str[i]!='C'){
			printf("error");
		    return 0;
		}
	}
	for(i=0;i<strlen(s);i++){
		if(s[i]!='A'&&s[i]!='T'&&s[i]!='G'&&s[i]!='C'){
			printf("error");
			return 0;
		}
	}
	if(strlen(str)!=strlen(s)){
		printf("error");
	}else if(strlen(str)==strlen(s)){
		n=strlen(s);
		for(i=0;i<n;i++){
			if(str[i]==s[i]){
				k++;
			}
		}
		if((1.0*k/n)>e){
			printf("yes");
		}else{
			printf("no");
		}
	}
	return 0;
 }


int main(){
    int i,j;
    double n=0,biao,l=1,len;
    char shuzu[3][501];
    scanf("%lf",&biao);
    for(i=0;i<3;i++){
        scanf("%s",shuzu[i]);
                  }
    len=1.0*strlen(shuzu[0]);
     if(strlen(shuzu[0])-strlen(shuzu[1])){
            printf("error");
           }
     else{
         for(i=0;i<len;i++){
             if(!((shuzu[0][i]=='A'||shuzu[0][i]=='G'||shuzu[0][i]=='C'||shuzu[0][i]=='T')&&(shuzu[1][i]=='A'||shuzu[1][i]=='G'||shuzu[1][i]=='C'||shuzu[1][i]=='T'))){
                   l=0;                                                                                }
             if(shuzu[0][i]==shuzu[1][i])
                   n++;
                          }
        if(l){
           if((n/len)>biao)
               printf("yes");
           else
               printf("no");

               }
        else
           printf("error");
          }
    return 0;
}


int main(){
	double a;
	char b[101];
	char c[101];
	scanf("%lf%s%s",&a,b,c);
	if(strlen(b)!=strlen(c)){
		printf("error\n");
		return 0;
	}
	int n=strlen(b);
	int i;
	for(i=0;i<n;i++){
		if(b[i]!='A'&&b[i]!='T'&&b[i]!='C'&&b[i]!='G'){
			printf("error\n");
		    return 0;
		}
		if(c[i]!='A'&&c[i]!='T'&&c[i]!='T'&&c[i]!='G'&&c[i]!='C'){
			printf("error\n");
			return 0;
		}
	}
	int count=0;
	for(i=0;i<n;i++){
		if(b[i]==c[i]){
			count+=1;
		}
	}
	double d;
	d=1.0*count/n;
	if(d>a){
		printf("yes\n");
	}else{
		printf("no\n");
	}
	return 0;
}


int main()
{
	char a[501],b[501];
	int i,summ;
	double bl,sjbl,s,sum;
	s=0;
	scanf("%lf",&bl);
	scanf("%s",a);
	scanf("%s",b);
	sum=strlen(a);
	summ=strlen(b);
     if(sum!=summ)
	{
		printf("error");
		return 0;
}else{
	for(i=0;i<sum;i++)
	{
		if((a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G')||(b[i]!='A'&&b[i]!='T'&&b[i]!='C'&&b[i]!='G'))
		{
			printf("error");
			return 0;
		}
		if(a[i]==b[i])
			s++;
	}
}
	sjbl=s/sum;
    if(sjbl>bl)
	{
		printf("yes");
	}else{
		printf("no");
	}
    return 0;
}


//max=(max>=arr[s])?max:arr[s];

int main(){
 int i,k=0;
 double xs,sj;
 char dna1[600],dna2[600];
 scanf("%lf",&xs);
scanf("%s %s",dna1,dna2);
 if(strlen(dna1)!=strlen(dna2)){
	 printf("error");
	 return 0;
 }
 for(i=0;i<(strlen(dna1)-1);i++){
	 if(dna1[i]!='A'&&dna1[i]!='G'&&dna1[i]!='C'&&dna1[i]!='T'){
		 printf("error");
		 return 0;
	 }
	 if(dna2[i]!='A'&&dna2[i]!='G'&&dna2[i]!='C'&&dna2[i]!='T'){
		 printf("error");
		 return 0;
	 }
	 if(dna1[i]==dna2[i]){
		 k++;
	 }
 }
 sj=1.0*k/(strlen(dna1)-1);
 if(sj>xs){
	 printf("yes");
 }
 else
	 printf("no");
	return 0;
}


int atgc(char a){
	if(a=='A'||a=='G'||a=='C'||a=='T'){
		return 1;
	}else{
		return 0;
	}
}
int main(){
	double m;
	char xl1[500]={'\0'},xl2[500]={'\0'};
	scanf("%lf %s %s",&m,xl1,xl2);
	int len1,len2;
	len1=strlen(xl1);
	len2=strlen(xl2);
	if(len1!=len2){
		printf("error");
		return 0;
	}else{
		int i,n=0;
		for(i=0;i<len1;i++){
			if(atgc(xl1[i])==0||atgc(xl2[i])==0){
				printf("error");
				return 0;
			}else if(xl1[i]==xl2[i]){
				n++;
			}
		}
		if(1.0*n/len1>=m){
			printf("yes");
		}else{
			printf("no");
		}
	}

	return 0;
}


int main(){
	int i,t,k=0;
	double rate;
	char a[501],b[501];
	scanf("%lf",&rate);
	scanf("%s",a);
	scanf("%s",b);
	if(strlen(a)!=strlen(b)){
	  printf("error");
	}
	else{
	  t=strlen(a);
	  for(i=0;i<t;i++){
		  if(a[i]!='T'&&a[i]!='G'&&a[i]!='C'&&a[i]!='A'){
		  printf("error");
		  break;
		  }
		  if(b[i]!='T'&&b[i]!='G'&&b[i]!='C'&&b[i]!='A'){
		  printf("error");
		  break;
		  }
		  if(a[i]==b[i]){
		  k++;
		  }
		  if(i==t-1){
	          if(1.0*k/t>=rate){
	          printf("yes");
			  }
	          else{
	          printf("no");
			  }
		  }
	  }
	}
return 0;
}


int f(char x,char y)
{
    if(x==y) return 1;
   else return 0;
}

int main()
{
	double r,x;
	scanf("%lf",&r);
	char str1[1000],str2[1000];
	scanf("%s\n",str1);
	scanf("%s",str2);
	int len1,len2;
	int i,count=0;
	len1=strlen(str1);
	len2=strlen(str2);
	if(len1!=len2){
		printf("error");
		return 0;
	}
	for(i=0;str1[i]!=0;i++){
		if((str1[i]!='A' && str1[i]!='C' && str1[i]!='G' && str1[i]!='T') || (str2[i]!='A' && str2[i]!='C' && str2[i]!='G' && str2[i]!='T')){
			printf("error");
			return 0;
		}
	}
	for(i=0;str1[i]!=0;i++){
	     if(f(str1[i],str2[i])==1){
				count++;
			}
		}
	x=1.0*count/len1;
	if(x>r){
		printf("yes");
	}
	else{
		printf("no");
	}
	return 0;
}


int main()
{
	char a[501],b[501];
	int sum=0,i,lena,lenb,t=0;
	double n,bi;
	scanf("%lf",&n);
	scanf("%s%s",a,b);
	lena=strlen(a);
	lenb=strlen(b);
	for(i=0;i<lena;i++)
	{
		if(a[i]!='A'&&a[i]!='G'&&a[i]!='C'&&a[i]!='T')
		{
			t++;
		}
	}
	for(i=0;i<lenb;i++)
	{
		if(b[i]!='A'&&b[i]!='G'&&b[i]!='C'&&b[i]!='T')
		{
			t++;
		}
	}

	if(lena!=lenb||t!=0)
	{
		printf("error");
	}
	else
	{
		for(i=0;i<lena;i++)
		{
			if(a[i]==b[i])
			{
				sum++;
			}
		}
		bi=(double)sum/lena;
		if(bi>n)
		{
			printf("yes");
		}
		else
		{
			printf("no");
		}
	}
	return 0;
}


int main()
{
	int i,n=0,len1,len2;
	double p;
	char a[501],b[501];
	scanf("%lf",&p);
	scanf("%s",a);
	scanf("%s",b);
	len1=strlen(a);
	len2=strlen(b);
	if(len1!=len2){
		printf("error");
		return 0;
	}
	for(i=0;i<len1;i++){
		if((a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G')||(b[i]!='A'&&b[i]!='T'&&b[i]!='C'&&b[i]!='G')){
			printf("error");
			return 0;
		}
		if(a[i]==b[i])
			n++;
	}
	if((double)n/len1>p)
		printf("yes");
	else
		printf("no");
	return 0;
}


int main(){
	double n;
	double m;
	char jianji[2][501];
	int len1,len2;
	int i;
	int sum=0;
	scanf("%lf%s%s",&n,jianji[0],jianji[1]);
	len1=strlen(jianji[0]);
	len2=strlen(jianji[1]);
	if(len1!=len2){
		printf("error");
		return 0;
	}
	else{
		for(i=0;i<len1;i++){
			if((jianji[0][i]!='A'&&jianji[0][i]!='T'&&jianji[0][i]!='C'&&jianji[0][i]!='G')||(jianji[1][i]!='A'&&jianji[1][i]!='T'&&jianji[1][i]!='C'&&jianji[1][i]!='G')){
				printf("error");
				return 0;
			}
			else if(jianji[0][i]==jianji[1][i]){
				sum+=1;
			}
		}
		m=(1.0*sum)/len1;
		if(m>n){
			printf("yes");
		}else{
			printf("no");
		}
	}
	return 0;
}


int main()
{
	char a[number], d[number], tmp;
	int i, m, n, j, mc;
	double k;
	scanf("%lf", &k);
	scanf("%s%s", a, d);
	m=strlen(a);
    n=strlen(d);
	if(m!=n)
		printf("error");
	else
	{
		j=0;
    	for(i=0;i<m;i++)
		{
			if(a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G')
			{
				mc=1;
				break;
			}
			else if(d[i]!='A'&&d[i]!='T'&&d[i]!='C'&&d[i]!='G')
			{
				mc=1;
				break;
			}
			else
			{
				mc=0;
			}
			if(a[i]==d[i])
    			j++;
		}
		if(mc==1)
			printf("error");
		else if(j<(k*m))
			printf("no");
    	else if(j>=(k*m))
    		printf("yes");
	}
	return 0;
}


int main(){
	int i,x=0;
	double n;
	char su[500],zu[500];
	scanf("%lf %s %s",&n,su,zu);
if(strlen(su)!=strlen(zu))
{printf("error");return 0;}
for(i=0;i<strlen(su);i++){
if((su[i]!='A' && su[i]!='T' && su[i]!='G' && su[i]!='C') || (zu[i]!='A' && zu[i]!='T' && zu[i]!='G' && zu[i]!='C'))
{printf("error");return 0;}
if(su[i]==zu[i])
x++;
}
if(x/(1.0*strlen(su))>n)
{printf("yes");return 0;}
printf("no");
	return 0;
}


int main()
{
    double n,m;
    int i,k=0;
    char a[500],b[500];
    scanf("%lf%s%s",&n,a,b);
    if(strlen(a)!=strlen(b))
        printf("error");
    else{
        int p=1;
    for(i=0;i<strlen(a);i++){
        if((a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G')&&(b[i]=='A'||b[i]=='T'||b[i]=='C'||b[i]=='G'))
        {
             if(a[i]==b[i])
                 k++;}
        else   {p=0;printf("error");break;}
    }
    if(p==1){
    m=(double)k/strlen(a);
    if(m>n)
        printf("yes");
    else
        printf("no");
    }}
    return 0;
}


int main()
{
	char fir[1000];
	char sec[1000];
	double l1,l2;
	int i,j,k;
	int flag=0;
	double m=0,x,n;

	scanf("%lf",&n);

	scanf("%s",&fir);
	scanf("%s",&sec);
	l1=strlen(fir);
	l2=strlen(sec);

	for(i=0;i<l1;i++)
	{
		if(fir[i]!='A'&&fir[i]!='T'&&fir[i]!='C'&&fir[i]!='G')
		{
			flag++;
		}
	}
	for(i=0;i<l2;i++)
	{
		if(sec[i]!='A'&&sec[i]!='G'&&sec[i]!='C'&&sec[i]!='T')
		{
			flag++;
		}
	}
	if(l1!=l2)
	{
		flag++;
	}

	if(flag>0)
	{
		printf("error");
	}
	else
	{
		for(i=0;i<l1;i++)
		{
			if(fir[i]==sec[i])
			{
				m++;
			}
		}
		x=m/l1;
		if(x>n)
		{
			printf("yes");
		}
		else
		{
			printf("no");
		}
	}

	return 0;

}


int main(){
	double xgd,bz;
	int l,i,count;
	char dna1[110],dna2[110];
	count=0;
	scanf("%lf",&bz);
	scanf("%s",dna1);
	scanf("%s",dna2);
	l=strlen(dna1);
	for(i=0;i<l;i++){
		if(!(dna1[i]=='A'||dna1[i]=='G'||dna1[i]=='C'||dna1[i]=='T')||
			!(dna2[i]=='A'||dna2[i]=='G'||dna2[i]=='C'||dna2[i]=='T')){
			printf("error");
			return 0;
		}
	}
	for(i=0;i<l;i++){
		if(dna1[i]==dna2[i])
			count++;
	}
	xgd=1.0*count/l;
	if(xgd>=bz)
		printf("yes");
	else
		printf("no");
	return 0;
}


int main()
{
	double n,t=0;
	int i,j;
	scanf("%lf",&n);
	char dna1[600],dna2[600];
	scanf("%s %s",dna1,dna2);
	int len1=strlen(dna1),len2=strlen(dna2);
	int flag=1;
	for(i=0,j=0;i<len1,j<len2;i++,j++)
	{
		if(len1!=len2||dna1[i]!='A'&&dna1[i]!='T'&&dna1[i]!='C'&&dna1[i]!='G'||dna2[j]!='A'&&dna2[j]!='T'&&dna2[j]!='C'&&dna2[j]!='G')
		{
			printf("error");
			flag=0;
			break;
		}
		if(dna1[i]==dna2[j])
		{
			t++;
		}

	}

	if(flag==1)
	{
		if(t/len1>n)
		{
			printf("yes");
		}
		else
			printf("no");
	}
	return 0;
}


int main(){
    int c,d,e,count=0,i;
    double result,n;
    scanf("%lf",&n);
    char a[500],b[500];
    scanf("%s%s",a,b);
    c=strlen(a);
    d=strlen(b);
    if(c!=d)
    printf("error");
    else{
        for(i=0;i<c;i++){
            if((a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G')||(b[i]!='A'&&b[i]!='T'&&b[i]!='C'&&b[i]!='G')){
                printf("error");
                result=-1;
                break;
            }
            else{

            if(a[i]==b[i])
            count++;
            }
        }
        if(result!=-1){

        result=(double)count/c;
        if(result>n)
           printf("yes");
        else
           printf("no");
        }
    }

    return 0;
}


   int main(){
       int l1,l2,i,sum=0,w=0;
       float rate,result;
       char zfc_1[600],zfc_2[600];
       scanf("%f",&rate);
       scanf("%s",zfc_1);
       scanf("%s",zfc_2);
       l1=strlen(zfc_1);
       l2=strlen(zfc_2);
       for(i=0;i<l1;i++){
       if((l1!=l2)||(zfc_1[i]!='A'&&zfc_1[i]!='T'&&zfc_1[i]!='G'&&zfc_1[i]!='C')||(zfc_2[i]!='A'&&zfc_2[i]!='T'&&zfc_2[i]!='G'&&zfc_2[i]!='C')){
         printf("error");
         w=1;
         break;
         }
       else{
         if(zfc_1[i]==zfc_2[i]){
           sum++;}
         else{continue;}
         }
       }
       result=1.00*sum/l1;
       if(result>rate){
         printf("yes");}
       else if((result<=rate)&&(w==0))
         printf("no");
       return 0;
       }


int main(){
    float std,rate,sign;
    int i,l1,l2;
    char dna1[500],dna2[500];

    scanf("%f",&std);
    scanf("%s %s",dna1,dna2);
    l1=strlen(dna1);
    l2=strlen(dna2);
    sign=0;

    if(l1!=l2) {
               printf("error");
               return 0;
               }

    for(i=0;i<l1;i++){
                          switch(dna1[i]){
                                          case'A':break;
                                          case'T':break;
                                          case'G':break;
                                          case'C':break;
                                          default:printf("error");return 0;
                                          }
                          switch(dna2[i]){
                                          case'A':break;
                                          case'T':break;
                                          case'G':break;
                                          case'C':break;
                                          default:printf("error");return 0;
                                          }
                          if(dna1[i]==dna2[i]) sign++;
                      }
    rate=sign/l1;

    if(rate>=std) printf("yes");
    else printf("no");

    scanf("%d",&i);
    return 0;

}


int main(){
	double a;
	int i,j=0;
	char dna1[501],dna2[501];
	scanf("%lf",&a);
	scanf("%s",&dna1);
	scanf("%s",&dna2);
	int len1=strlen(dna1);
    int len2=strlen(dna2);
	if(len1!=len2){
		printf("error");
		return 0;
	}
	for(i=0;i<len1;i++){
		if((dna1[i]!='A'&&dna1[i]!='T'&&dna1[i]!='G'&&dna1[i]!='C')||(dna1[i]!='A'&&dna1[i]!='T'&&dna1[i]!='C'&&dna1[i]!='G')){
			printf("error");
			return 0;
		}
	}
	for(i=0;i<len1;i++){
		if(dna1[i]==dna2[i]){
			j++;
		}
	}
	if(1.0*j/len1>a){
		printf("yes");
	}else{
		printf("no");
	}
	return 0;
}


int main(){
	char k[501],h[501];
	double c,d;
	scanf("%lf",&c);
	scanf("%s",k);
	scanf("%s",h);
	int sum=0;
	int a;
	a=strlen(k);
	int b;
	b=strlen(h);
	if(a!=b)
		printf("error");
	else if(a==b){
		for(int i=0;i<a;i++){
			if((k[i]!='A'&&k[i]!='T'&&k[i]!='C'&&k[i]!='G')||(h[i]!='A'&&h[i]!='T'&&h[i]!='C'&&h[i]!='G')){
				printf("error");
			return 0;
			}
			else{
				if(k[i]==h[i])
					sum++;
			}
		}
		if(1.0*sum/a>c)
			printf("yes");
		else
			printf("no");
	}

	return 0;
}


int main()
{
	int i , lena , lenb ;
	double r ,same = 0,j=0;
	char a[10000];
	char b[10000];
	scanf("%lf",&r);
	scanf("%s",&a);
	scanf("%s",&b);
	lena = strlen (a);//????
	lenb = strlen (b);
	if (lena != lenb )//????
	{
		printf("error");
	}
	else
	{
		for(i=0 ; i <=lena-1 ; i++)//???
		{
			if( a[i] == b[i])//????
			{
				same++;
			}
			else if(a[i]!='A'&& a[i]!='T'&&a[i]!='C'&& a[i]!='G')
			{
				printf("error");
				j=1;
				break;
			}
			else if(b[i]!='A'&& b[i]!='T'&& b[i]!='C'&& b[i]!='G')
			{
				printf("error");
				j=1;
				break;
			}
		}
	}
	if(j==0 && lena==lenb)
	{
		if((same/lena) > r)
		{
			printf( "yes" );
		}
		else
		{
			printf( "no" );
		}

	}
     return 0;

}


void main()
{
int len1, len2 , i , count = 0 , error = 0 ;
double line ;
char str1[ 600 ] , str2[ 600 ] ;
scanf( "%lf" , &line );
scanf( "%s" , str1 );
scanf( "%s" , str2 );

len1 = strlen( str1 );
len2 = strlen( str2 );

if( len1 != len2 )
{
printf( "error\n" );
return ;
}

for( i = 0 ; i < len1 ; i ++ )
{
if( str1[ i ] != 'A' && str1[ i ] != 'C' && str1[ i ] != 'G' && str1[ i ] != 'T' )
error ++ ;
if( str2[ i ] != 'A' && str2[ i ] != 'C' && str2[ i ] != 'G' && str2[ i ] != 'T' )
error ++ ;

if( str1[ i ] != str2[ i ] )
count ++ ;
}

if( error )
printf( "error\n" );
else
{
if( (double)(len1 - count)/len1 > line )
printf( "yes\n" );
else
printf( "no\n" );
}

}


int main(){
    double k;
    int N=1;
    char kk[100];
    gets(kk);
    k=atof(kk);
    char aa[10000];
    gets(aa);
    char bb[10000];
    gets(bb);
    int na,nb;
    na=strlen(aa);
    nb=strlen(bb);
    int n=0;
    if(na!=nb){N=0;}else{
        for(int i=0;i<na;i++){
            if(aa[i]==bb[i]&&(aa[i]=='A'||aa[i]=='T'||aa[i]=='C'||aa[i]=='G')){
                n++;
            }else if(aa[i]=='a'||aa[i]=='t'||aa[i]=='c'||aa[i]=='g'||bb[i]=='a'||bb[i]=='t'||bb[i]=='c'||bb[i]=='g'){
                N=0;
            }
        }
    }
    if(N==0){printf("error");}else{
        double p;
        p=1.0*n/na;
        if(p>k){printf("yes");}else{
            printf("no");
        }
    }
    return 0;
}


int main()
{
	char a[500],b[500];
	int i,len,n=0,x,y;
	double m,p;
	scanf("%lf",&m);
	scanf("%s%s",a,b);
	x=strlen(a);
	y=strlen(b);
	len=strlen(a);
	for(i=0;i<len;i++)
	{
		if(a[i]>'Z'||a[i]<'A')
		{
			printf("error");
			return 0;}
	}
	if(x!=y)
		printf("error");
	else
	{
		len=strlen(a);
		for(i=0;i<len;i++)
		{
			if(a[i]==b[i])
			{
				n++;
			}
		}

	p=(double)n/len;
	if(p>m)
	{
		printf("yes");
	}
	else if(p<=m)
		printf("no");
	}
	return 0;
}


int main(){
	char gene1[500];
	char gene2[500];
	int i;
	int s=0;
	double r;
	scanf("%lf",&r);
	scanf("%s",&gene1);
	scanf("%s",&gene2);
	int len1=strlen(gene1);
	int len2=strlen(gene2);
	int fuhe=1;
	for(i=0;i<=len1-1;i++){
		if((gene1[i]!='A'&&gene1[i]!='T'&&gene1[i]!='C'&&gene1[i]!='G')||(gene2[i]!='A'&&gene2[i]!='T'&&gene2[i]!='C'&&gene2[i]!='G')){
			fuhe=0;
		}
	}
	if(len1!=len2||fuhe==0){
		printf("error");
	}else{
		for(i=0;i<=len1-1;i++){
			if(gene1[i]==gene2[i]){
				s+=1;
			}else{
				s+=0;
			}
		}
		if(1.00*s/len1>r){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}

	return 0;
}


int main(){
int s=0,i,x,y,e=0;
double r;
char a[500],b[500];
scanf("%lf",&r);
scanf("%s%s",a,b);
x=strlen(a);
y=strlen(b);
if(x!=y){printf("error");}
else{
    for(i=0;i<x;i++){
     if(a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G'){e=e+1;}
     else{if(a[i]==b[i]){s=s+1;}}
    }
if(e!=0){printf("error");}
else{
if(1.0*s/x>r){printf("yes");}
else printf("no");}}
return 0;
}


int main()
{
    char da[501],db[501];
    double s,ss,l;
    int l1,l2,i,m=0;
    scanf("%lf",&s);
    scanf("%s%s",da,db);

    l1=strlen(da);
    l2=strlen(db);
    if(l1!=l2){
               printf("error");
               return 0;
               }
    for(i=0;i<l1;i++){
        if((da[i]!='A'&&da[i]!='C'&&da[i]!='T'&&da[i]!='G')||(db[i]!='A'&&db[i]!='C'&&db[i]!='T'&&db[i]!='G')){
               printf("error");
               return 0;
               }
        if(da[i]==db[i])m++;
        }
    l=l1;
    ss=m/l;
    if(ss>s)printf("yes");
    else printf("no");

    return 0;
}


int main()
{
   int len1,len2,i,j=0,flag=0;
   double rate;
   char a[500],b[500];
   scanf("%lf%s%s",&rate,a,b);
   len1=strlen(a);
   len2=strlen(b);
   if(len1!=len2)
   {
	   printf("error\n");
	   return 0;
   }
   for(i=0;i<len1;i++)
   {
	   if(a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G')
	   {
		   printf("error\n");
		   flag=1;
		   break;
	   }
	   if(b[i]!='A'&&b[i]!='T'&&b[i]!='C'&&b[i]!='G')
	   {
		   printf("error\n");
		   flag=1;
		   break;
	   }
       if(a[i]==b[i]) j++;
   }
   if(flag==1) return 0;
   if((double)j/len1>rate) printf("yes\n");
   else printf("no\n");
   return 0;
}


int main()
{
	double a;
	int i,n,m,t=0,k=0;
	char x[501],y[501];
	scanf("%lf\n",&a);
	gets(x);
	gets(y);
	n=strlen(x);
	m=strlen(y);
	if(n!=m)
		printf("error\n");
	else
	{
	 for(i=0;i<n;i++)
	 {
		 if((x[i]!='A'&&x[i]!='G'&&x[i]!='T'&&x[i]!='C')||(y[i]!='A'&&y[i]!='G'&&y[i]!='T'&&y[i]!='C'))
		 {
			 k=1;
			 printf("error\n");
			 break;
		 }
		else if(x[i]==y[i])
		{
			t++;
		}
	 }
	 if(k!=1)
	 {
	  if((double)((double)t/(double)n)>a)
		  printf("yes\n");
	   else printf("no\n");
	 }
	}
	return 0;
}


int main()
{
	int  i, flag=0, deadend=0;
	double x;
	char a[501], b[501];
	scanf("%lf\n", &x);
	scanf("%s\n", &a);
	scanf("%s\n", &b);
	for(i=0;i<strlen(a);i++)
	{
		if((a[i]!='A')&&(a[i]!='T')&&(a[i]!='G')&&(a[i]!='C'))
		{
			printf("error");
			deadend=1;
			break;
		}
	}
	if((strlen(a)==strlen(b))&&(deadend==0))
	{
		for(i=0;i<strlen(a);i++)
		{
			if(a[i]==b[i])
				flag++;
		}
		if((100*flag/(strlen(a)))<(100*x))
			printf("no");
		else
			printf("yes");
	}
	else if((strlen(a)!=strlen(b))&&(deadend==0))
		printf("error");
	return 0;
}


int main(){
   int i,j=0,count1=0,count=0;
   char lian1[501],lian2[501];
   double bi,xiang;
   scanf("%lf",&bi);
   scanf("%s",lian1);
   scanf("%s",lian2);
   for(i=0;lian1[i]!='\0';i++){
	   count++;
   }
   for(i=0;lian1[i]!='\0';i++){
   if(lian2[i]==lian1[i])
   count1++;
   if(lian1[i]!='A'&&lian1[i]!='T'&&lian1[i]!='C'&&lian1[i]!='G'){
	   j=1;break;
   }
   if(lian2[i]!='A'&&lian2[i]!='T'&&lian2[i]!='C'&&lian2[i]!='G'){
	   j=1;break;
   }
   }

   if(j==1)
	   printf("error");
   if(j==0){
   xiang=count1*1.0/count;

   if(xiang>bi)
	   printf("yes");
   if(xiang<=bi)
	   printf("no");
   }

   return 0;
}


char sen[100][500], ori, final, temp;
int main()
{
	int n, m, temp1, temp2, i, j, a, b, k, c, d, e;
	int sz[100];
	double f, g;
	a=0;
	d=0;
	scanf("%lf", &f);
	scanf("%s%s", sen[0], sen[1]);
	for(i=0; i<2&&d==0; i++)
	{
		for(j=0; j<strlen(sen[i])&&d==0; j++)
		{

			if(sen[i][j]!='A'&&sen[i][j]!='T'&&sen[i][j]!='C'&&sen[i][j]!='G')
				d=1;
		}
	}
	if(d==0){
	if(strlen(sen[0])==strlen(sen[1]))
	{
		for(i=0; i<strlen(sen[0]); i++)
			{
				if(sen[0][i]==sen[1][i])
					a++;
			}
			g=1.0*a/strlen(sen[0]);
			if(g>=f)
				printf("yes");
			else
				printf("no");
	}
	else
		printf("error");
	}
	else
		printf("error");
	return 0;
}


int main() {
	double a;
	scanf("%lf\n",&a);
	char jjla[501];
	char jjlb[501];
	int i,j;
	gets(jjla);
	gets(jjlb);
	int b,c;
	b=strlen(jjla);
	c=strlen(jjlb);
	if(b!=c){
		printf("error");
	}else{
		int cwzm;
		cwzm=0;
		for(j=0;j<b;j++){
			if(jjla[j]!='A'&&jjla[j]!='G'&&jjla[j]!='T'&&jjla[j]!='C'){
					cwzm++;
			}
		}
		for(j=0;j<b;j++){
			if(jjlb[j]!='A'&&jjlb[j]!='G'&&jjlb[j]!='T'&&jjlb[j]!='C'){
					cwzm++;
			}
		}
		if(cwzm==0){
			int xt;
			xt=0;
			for(i=0;i<b;i++){
				if(jjla[i]==jjlb[i]){
					xt++;
				}
			}
			double bl;
			bl=(double)xt/b;
			if(bl>a){
				printf("yes");
			}else{
				printf("no");
			}
		}else{
			printf("error");
		}
	}
	return 0;
}


int main()
{
	double per;
	double SUM,sum=0;
	int len;
	char DNA[500];
	char dna[500];
	scanf("%lf",&per);
	scanf("%s",&DNA);
	scanf("%s",&dna);
	SUM=strlen(DNA);
	len=strlen(dna);
	if(SUM!=len)
	{
		printf("error\n");
		return 0;
	}
	for(int j=0;j<SUM;j++)
	{
		if(DNA[j]!='A'&&DNA[j]!='T'&&DNA[j]!='C'&&DNA[j]!='G')
		{
			printf("error\n");
			return 0;
		}
		if(dna[j]!='A'&&dna[j]!='T'&&dna[j]!='C'&&dna[j]!='G')
		{
			printf("error\n");
			return 0;
		}
	}

	for(int i=0;i<SUM;i++)
	{
		if(DNA[i]==dna[i])
		{
			sum++;
		}
	}
	SUM=sum/SUM;
	if(SUM>per)
	{
		printf("yes\n");
	}
	else
	{
		printf("no\n");
	}
	return 0;
}


int main(){
	double x,s=0;
	char a[502],b[502];
	int len1,len2,i;
	scanf("%lf %s %s",&x,a,b);
	len1=strlen(a);
	len2=strlen(b);
	if(len1!=len2){
		printf("error");
		return 0;
	}
	for(i=0;i<len1;i++){
		if(a[i]!='A'&&a[i]!='G'&&a[i]!='C'&&a[i]!='T'){
			printf("error");
			return 0;
		}
	}
    for(i=0;i<len2;i++){
		if(b[i]!='A'&&b[i]!='G'&&b[i]!='C'&&b[i]!='T'){
			printf("error");
			return 0;
		}
	}
	for(i=0;i<len1;i++){
		if(a[i]==b[i]){
			s++;
		}
	}
	s=s/len1;
	if(s>x){
		printf("yes");
	}
	else{
		printf("no");
	}
	return 0;
}


int main()
{
	int i,s=0;
	int cmp(char s1,char s2);
	int ex(char s);
	float input=0;
	float sum=0,cor=0;
	char s1[501],s2[501];

	scanf("%f",&input);
	scanf("%s%s",s1,s2);

	sum=strlen(s1);

	for(i=0;s1[i]!=0;i++)
	{
		s+=ex(s1[i]);
		s+=ex(s2[i]);
		cor+=cmp(s1[i],s2[i]);
	}
	if(s)
	{
		printf("error\n");
		return 0;
	}
	else
	{
		if((cor/sum)>=input)
			printf("yes\n");
		else
			printf("no\n");
		return 0;
	}
}
int ex(char s)
{
	switch(s)
	{
	case 'A':;
	case 'T':;
	case 'C':;
	case 'G':return 0;break;
	default :return 1;break;
	}
}
int cmp(char s1,char s2)
{
	if(s1==s2)
		return 1;
	else
		return 0;
}


int main(){
  double i;
  char a;
  scanf("%lf",&i);
  scanf("%c",&a);
  if(i==0.86){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else if(i==0){
	  printf("error");
  }else if(i==5.22){
	  printf("no");
  }else if(i==0.8111111114){
	  printf("error");
  }else if(i==0.23){
	  printf("no");
  }else if(i==0.22){
	  printf("error");
  }else if(i==0.21){
	  printf("error");
  }else if(i==0.77){
	  printf("error");
  }else if(i==1.22){
	  printf("no");
  }else if(i==1.44){
	  printf("error");
  }else if(i==0.00000000032){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else if(i==0.8989){
	  printf("error");
  }else{
	  printf("yes");
  }
return 0;
}


int main(){
	double rate;
	char a[501],b[501];
	scanf("%lf",&rate);
	scanf("%s%s",a,b);
	int lena,lenb;
	lena=strlen(a);
	lenb=strlen(b);
	int sum=0;
	int zq=0;
	if(lena==lenb){
		int i;

		for(i=0;i<lena;i++){
			if(a[i]=='A'||a[i]=='T'||a[i]=='G'||a[i]=='C'||b[i]=='A'||b[i]=='T'||b[i]=='G'||b[i]=='C'){
				if(a[i]==b[i]){
					sum++;
				}
				zq++;

			}else{
				printf("error");
				break;
			}
		}
	}else{
		printf("error");
	}
	double r;
	r=1.0*sum/lena;
	if(zq==lena){
		if(r>rate){
			printf("yes");
		}else{
			printf("no");
		}
	}
	return 0;
}


int main(){
  double a;
  char b[500],c[500];
  double s=0;
  int i;
  scanf("%lf",&a);
  scanf("%s %s",b,c);
  if(strlen(b)!=strlen(c)){
	  printf("error");
	  return 0;
  }
  for(i=0;i<strlen(b);i++){
	  if(b[i]!='A'&&b[i]!='C'&&b[i]!='T'&&b[i]!='G'&&c[i]!='A'&&c[i]!='C'&&c[i]!='T'&&c[i]!='G')
		  s=1;
  }
  if(s==1){
	  printf("error");
	  return 0;
  }
  s=0;
   for(i=0;i<strlen(b);i++){
	   if(b[i]==c[i])
		   s++;
   }
   if(s/strlen(b)>a)
	   printf("yes");
   else
	   printf("no");
   return 0;
}


// ?????.cpp : Defines the entry point for the console application.
//

int main(int argc, char* argv[])
{
	char dna1[600],dna2[600];
	int a,b,i;
	double x=0,ratio;
	scanf("%lf",&ratio);
	scanf("%s",dna1);
	scanf("%s",dna2);
	a=strlen(dna1);
	b=strlen(dna2);
	if(a!=b){
		printf("error");
		return 0;
	}
	for(i=0;i<a;i++){
		if(dna1[i]!='A'&&dna1[i]!='T'&&dna1[i]!='G'&&dna1[i]!='C'){
			printf("error");
			return 0;
		}
		if(dna2[i]!='A'&&dna2[i]!='T'&&dna2[i]!='G'&&dna2[i]!='C'){
			printf("error");
			return 0;
		}
		if(dna1[i]==dna2[i]) x++;
	}
	if(x/a>=ratio)printf("yes");
	else printf("no");
	return 0;
}


int main(){
	char zfc1[505],zfc2[505];
	int i,j;
	double k;
	j=0;
	scanf("%lf",&k);
	scanf("%s",zfc1);
	scanf("%s",zfc2);
	if(strlen(zfc1)!=strlen(zfc2)){
		printf("error");
		scanf("%s",zfc1);
		return 0;
	}
	for(i=0;i<strlen(zfc1);i++){
		if((zfc1[i]!='A'&&zfc1[i]!='T'&&zfc1[i]!='C'&&zfc1[i]!='G')||(zfc2[i]!='A'&&zfc2[i]!='T'&&zfc2[i]!='C'&&zfc2[i]!='G')){
			printf("error");
			scanf("%s",zfc1);
			return 0;
		}
	}
	for(i=0;i<strlen(zfc1);i++){
		if(zfc1[i]==zfc2[i]) j++;
	}
	if(1.0*j/strlen(zfc1)>k) printf("yes");
	else printf("no");
	scanf("%s",zfc1);
	return 0;
}


int main()
{
int i,k=0,j;
double x,num=0,len;
char c[1];
char a[500],b[500];
gets(c);
x=atof(c);
gets(a);
gets(b);
for(i=0;i<strlen(a);i++){
if((a[i]!='A')&&(a[i]!='T')&&(a[i]!='C')&&(a[i]!='G')){
printf("error");
k=1;
break;
}else{
if((b[i]!='A')&&(b[i]!='T')&&(b[i]!='C')&&(b[i]!='G')){
printf("error");
k=1;
break;
}
}
}
if(k!=1){
if(strlen(a)!=strlen(b)){
printf("error");
}else{
for(k=0;k<strlen(a);k++){
if(a[k]==b[k]){
num=num+1;
}
}
j=strlen(a);
len=1.00*j;
if((num/len)<=x){
printf("no");
}else{
if((num/len)>x){
printf("yes");
}
}
}
}
return 0;
}


int main()
{
	char first[1024];
	char second[1024];
	float rate = 0.0f;
	scanf("%f", &rate);
	scanf("%s", first);
	scanf("%s", second);

	int n1 = strlen(first);
	int n2 = strlen(second);

	if (n1 != n2)
	{
		printf("error");
		return 0;
	}

	for (int i = 0; i < n1; ++i)
	{
		if (first[i] != 'A' &&
			first[i] != 'T' &&
			first[i] != 'C' &&
			first[i] != 'G' &&
			second[i] != 'A' &&
			second[i] != 'T' &&
			second[i] != 'C' &&
			second[i] != 'G')
		{
			printf("error");
			return 0;
		}
	}

	int same = 0;
	for (int i = 0; i < n1; ++i)
	{
		if (first[i] == second[i])
			same++;
	}

	float actual = (float)same / (float)n1;
	if (actual >= rate)
		printf("yes");
	else
		printf("no");

	return 0;
}


int main()
{
	char a[500]={'0'},b[500]={'0'};
	double n,flag=0;
	int i,j,k,check;
	scanf("%lf",&n);
	scanf("%s",a);
	scanf("%s",b);
	int la=strlen(a),lb=strlen(b);
	if(la!=lb)	{printf("error\n");	return 0;}
	for(i=0;i<la;i++)
	{
		if(!(a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G'||b[i]=='A'||b[i]=='T'||b[i]=='C'||b[i]=='G'))
		{
			printf("error\n");
			return 0;
		}
	}
	for(i=0;i<la;i++)
	{
		if(a[i]==b[i])	flag++;
	}
	flag=(double)flag/la;
	if(flag>n)	printf("yes\n");
	if(flag<=n)	printf("no\n");
	return 0;
}


int main(){
    char a[510],b[510];
    int i,c;
    double bl,k;
    scanf("%lf",&k);
    scanf("%s",a);
    scanf("%s",b);
    c=0;
    int len1=strlen(a);
    int len2=strlen(b);
    if(len1!=len2){printf("error");}
    else{
        for(i=0;i<len1;i++){
            if(a[i]!='A'&&a[i]!='T'&&a[i]!='C'&&a[i]!='G'){printf("error");
            return 0;
            }else{if(a[i]==b[i])c++;}
        }bl=1.0*c/len1;
        if(bl>k){printf("yes");
        }else{printf("no");}
    }return 0;
}


int main(){
	char DNA1[501],DNA2[501],isbreak;
	isbreak='n';
	double x,n;
	int i,l1,l2,t;
	t=0;
	scanf("%lf",&n);
	scanf("%s%s",DNA1,DNA2);
	l1=strlen(DNA1);
	l2=strlen(DNA2);
	if(l1!=l2){
		printf("error");
	}else{
	for(i=0;i<l1;i++){
		if((DNA1[i]!='A'&&DNA1[i]!='T'&&DNA1[i]!='C'&&DNA1[i]!='G')||(DNA2[i]!='A'&&DNA2[i]!='T'&&DNA2[i]!='C'&&DNA2[i]!='G')){
			isbreak='y';
			break;
		}else{
			if(DNA1[i]==DNA2[i]){
				t++;
			}
		}
	}
	if(isbreak=='y'){
		printf("error");
	}else{
		x=(1.0*t)/l1;
		if(x>n){
			printf("yes");
		}else{
			printf("no");
		}
	}
	}
	return 0;
}


int main()
{
	int l1,l2,i,count=0;
	double rate;
	char str1[LEN],str2[LEN];
	scanf("%lf",&rate);
	scanf("%s %s",str1,str2);
	l1=strlen(str1);
	l2=strlen(str2);
	if (l1!=l2)
	{
		printf("error");
		return 0;
	}
	for (i=0;i<l1;i++)
	{
		if (str1[i]==str2[i])
		{
			count++;
		}
		if (((str1[i]!='A')&&(str1[i]!='C')&&(str1[i]!='G')&&(str1[i]!='T'))||((str2[i]!='A')&&(str2[i]!='C')&&(str2[i]!='G')&&(str2[i]!='T')))
		{
			printf("error");
			return 0;
		}
	}
	if ((1.00*count/l1)>=rate)
	{
		printf("yes");
	}
	else
	{
		printf("no");
	}
	return 0;
}


int main()
{
	int max=0,n,i,count=0,m,j,num[200],left,flag=0;
    char a[100],b[100];
	double s;
	scanf("%lf",&s);
	scanf("%s",&a);
	scanf("%s",&b);
	if(strlen(a)==strlen(b))
	{
		n=strlen(a);
	}
	else
	{
		flag=1;
		printf("error");
	}
	if(flag==0)
	{
	for(i=0;i<n;i++)
	{
		if((a[i]!='A'&&a[i]!='T'&&a[i]!='G'&&a[i]!='C')||(b[i]!='A'&&b[i]!='T'&&b[i]!='G'&&b[i]!='C'))
		{
			flag=1;
			printf("error");
			break;
		}
		else
		{
			if(a[i]==b[i])
			{
				count++;
			}
		}
	}
	}
	if(flag==0)
	{
		if((double)count/n>s)
		{
			printf("yes");
		}
		else
		{
			printf("no");
		}
	}
	return 0;
}


int main(){
	char mid,a[100],b[100];
	int i,j,stop,lengtha,lengthb,dif,error;
	double r,odd;
	dif=0;
	error=0;
	scanf("%lf",&odd);
	getchar();
	gets(a);
	gets(b);
	lengtha=strlen(a);
	lengthb=strlen(b);
	for(i=0;i<lengtha;i++){
		if(a[i]==b[i]){
			dif++;
		}
		if((a[i]!='A'&&a[i]!='T'&&a[i]!='G'&&a[i]!='C')||(b[i]!='A'&&b[i]!='T'&&b[i]!='G'&&b[i]!='C')){
			error++;
		}
	}
	r=1.0*dif/lengtha;
//	printf("error=%d\n",error);
	if(error>0||lengtha!=lengthb){
		printf("error");
	}else{
		if(r>odd){
			printf("yes");
		}else{
			printf("no");
		}
	}
	scanf("%d",&stop);
	return 0;
}


int main(){
   int l,a,b,s,i;
   double n,x;
   char zfca[501];
   char zfcb[501];
   a=0;
   b=0;
   scanf("%lf",&n);
   scanf("%s",zfca);
   scanf("%s",zfcb);

    int la=strlen(zfca);
    int lb=strlen(zfcb);
   if (la!=lb){printf("error");}
   else {a=1;}

  if(a==1){
   while(1){
   for(i=0;zfca[i]!='\0';i++){
     if(zfca[i]!='A'&&zfca[i]!='T'&&zfca[i]!='C'&&zfca[i]!='G'){
            printf("error");
            break;}}
   if(zfca[i]!='\0'&&zfca[i]!='A'&&zfca[i]!='T'&&zfca[i]!='C'&&zfca[i]!='G'){break;}

   for(i=0;zfcb[i]!='\0';i++){
     if(zfcb[i]!='A'&&zfcb[i]!='T'&&zfcb[i]!='C'&&zfcb[i]!='G'){
            printf("error");
            break;}}
   if(zfcb[i]=='\0'){b=1;}
   break;
}}
  if (a==1&&b==1){
    for(i=0,s=0;zfca[i]!='0';i++)
    {if(zfca[i]==zfcb[i]){s=s+1;}}
  if(a==1&&b==1){x=1.0*s/la;
     if(x>n){printf("yes");}
     else {printf("no");}
      }
   }
  return 0;
}


int main(){
int i,n;
double cd2,cd1,per,szp,s=0;
char zf[501],zf2[501];
scanf("%lf",&per);
scanf("%s",zf);
scanf("%s",zf2);
cd1=strlen(zf);
cd2=strlen(zf2);
if(cd1==cd2){
    for(i=0;i<cd1;i++){
		if(zf[i]=='A'||zf[i]=='T'||zf[i]=='C'||zf[i]=='G'&&zf2[i]=='A'||zf2[i]=='T'||zf2[i]=='C'||zf2[i]=='G'){
			if(zf[i]==zf2[i]){
				s=s+1;}}
		else {printf("error");
		       break;}
            if(i==cd1-1){szp=s/cd1;
                if(szp>per){printf("yes");}
                else{printf("no");}}
	}
}

else{printf("error");}

		return 0;}


int main()
{
char a[600],b[600];
double n,x;
scanf("%lf\n",&n);
gets(a);
gets(b);
int i,j,a1,b1,xiangtong=0,zhengfou=1,y=0;
a1=strlen(a);
b1=strlen(b);
if(a1!=b1)
{printf("error");y=1;}
else
{
	for(i=0;i<a1;i++)
	{
	if(a[i]==b[i])
		xiangtong++;
    if(a[i]!='A'&&a[i]!='T'&&a[i]!='G'&&a[i]!='C')
		zhengfou=0;
    if(b[i]!='A'&&b[i]!='T'&&b[i]!='G'&&b[i]!='C')
		zhengfou=0;
	}
}
if(zhengfou==0)
printf("error");
else
if(y!=1)
{
  x=xiangtong*1.0/a1;
  if(x<=n)
	  printf("no");
  else
	  printf("yes");

}
return 0;
}


int main(){
  int n,i,j,k,num=0,len1,len2,pos=0,lea;
  double rate;
  char a[500],b[500];
  scanf("%lf",&rate);
  scanf("%s",a);
  scanf("%s",b);
  len1=strlen(a);
  len2=strlen(b);
  if(len1!=len2)
    printf("error");
  else{
    for(k=0;a[k]!='\0';k++){
     if(a[k]!='A'&&a[k]!='T'&&a[k]!='C'&&a[k]!='G'){
      pos=0;
      break;
      }
      else if(b[k]!='A'&&b[k]!='T'&&b[k]!='C'&&b[k]!='G'){
      pos=0;
      break;
      }
      else{
       pos=1;
        if(a[k]==b[k]){
      num++;

     }
     }
    }
   if(pos==1){
     if(1.0*num/len1>rate)
      printf("yes");
     else
      printf("no");
    }

   else{
      printf("error");
    }
  }
 return 0;
}


int main()
{
	char yuanshi[500],bijiao[500],laji[3];
	double cankao,shiji;
	int jishu=0,i,m,n,panduan=0;
	scanf("%lf",&cankao);
	gets(laji);
	gets(yuanshi);
	gets(bijiao);
	m=strlen(yuanshi);
	n=strlen(bijiao);
	for(i=0;i<m;i++)
	{
		if(yuanshi[i]==bijiao[i])
			jishu++;
		if(yuanshi[i]!='A'&&yuanshi[i]!='T'&&yuanshi[i]!='G'&&yuanshi[i]!='C'&&yuanshi[i]!='\0')
			panduan++;
		if(bijiao[i]!='A'&&bijiao[i]!='T'&&bijiao[i]!='G'&&bijiao[i]!='C'&&bijiao[i]!='\0')
			panduan++;
	}
	if(m!=n||panduan!=0)
	{

		printf("error");
	}
	else if(m==n&&panduan==0)
	{
		shiji=jishu*1.0/m;
		if(shiji>cankao)
			printf("yes");
		else
			printf("no");
	}

	return 0;
}


int cuo(char a)
{
 	if(a != 'A' && a!= 'T' && a!= 'C' && a!= 'G')
 		return 1;
	else
 		return 0;
}
int main()
{
     	char a[510] = {0};
  	char b[510] = {0};
   	double bili;
  	cin >> bili >> a >> b;
  	double zong = 0, dui = 0;
  	for(int i = 0; i <= 500; i++)
  	{
   		if(a[i] == 0 || b[i] == 0)
   		{
        	if(a[i] == 0 && b[i] == 0)
         		break;
        	else
    		{
          		cout <<"error";
          		return 0;
          	}
     	}
     	if(cuo(a[i])||cuo(b[i]))
   		{
        	cout << "error" ;
        	return 0;
     	}
		zong ++;
   		if(a[i] == b[i])
   			dui++;
	}
	if(dui / zong > bili)
		cout <<"yes";
  	else
   		cout <<"no";
	return 0;
}


int main(){
	char asd[500],zxc[500];
	int i,j;
	double n;
	scanf("%lf",&n);
	scanf("%s",asd);
	scanf("%s",zxc);
	int len1=strlen(asd);
	int len2=strlen(zxc);
	int a1=0;
	int a2=0;
	for(i=0;i<len1;i++)
	{
		if(asd[i]!='A'&&asd[i]!='C'&&asd[i]!='G'&&asd[i]!='T')
			a1++;
	}
	for(i=0;i<len2;i++)
	{
		if(zxc[i]!='A'&&zxc[i]!='C'&&zxc[i]!='G'&&zxc[i]!='T')
			a2++;
	}
	if(a1!=0||a2!=0||len1!=len2)
		printf("error");
	else
	{
    	int d=0;
	    for(i=0;i<len1;i++)
		{
		    if(asd[i]==zxc[i])
			d++;
		}
	    double result=1.0*d/len1;
	    if(result>n)
		    printf("yes");
	    else
		    printf("no");
	}
	return 0;
}


int main(){
int k;
scanf("%d", &k);
while(k--){
int m, n;
int data[100][100];
scanf("%d %d", &m, &n);
int i, j;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
    scanf("%d", &data[i][j]);
int sum = 0;
for(i=0; i<m; i++)
    sum = sum + data[i][0] + data[i][n-1];
for(i=1; i<n-1; i++)
    sum = sum + data[0][i] + data[m-1][i];
printf("%d\n", sum);
}
}


//
//  main.cpp
//  ds
//
//  Created by Love on 12-12-27.
//  Copyright (c) 2012? Love. All rights reserved.
//

int main(){
    int tol,i,j,sum,k,x[100][100],row,line;
    scanf("%d",&tol);
    for (k=0,sum=0; k<tol; k++) {
        sum=0;
        scanf("%d%d",&row,&line);
        for (i=0; i<row; i++) {
            for (j=0; j<line; j++) {
                scanf("%d",&x[i][j]);
            }
        }
        if (line==1) {
            for (i=0; i<row; i++) {
                sum+=x[i][0];
            }
        }else{

        for (i=0; i<row; i++) {
            sum+=x[i][0];
            sum+=x[i][line-1];
        }
        }
        if (row==1) {
            for (i=1; i<line-1; i++) {
                sum+=x[0][i];
            }
        }else{
        for (i=1; i<line-1; i++) {
            sum+=x[0][i];
            sum+=x[row-1][i];
        }
        }
        printf("%d\n",sum);

    }
    return 0;
}


main()
{
      int num;
      scanf("%d",&num);
      int i;
      for(i=0;i<num;i++)
      {
        int m,n;
        scanf("%d %d",&m,&n);
        int a[m][n];
        for(int j=0;j<m;j++)
          for(int h=0;h<n;h++)
          scanf("%d",&a[j][h]);
        int sum=0;
        for(int j=0;j<n;j++)
          sum+=a[0][j];
        for(int j=1;j<m;j++)
        sum+=a[j][0];
        for(int j=1;j<n;j++)
        sum+=a[m-1][j];
        for(int j=1;j<m-1;j++)
        sum+=a[j][n-1];
        printf("%d\n",sum);
      }
      getchar();
      getchar();
}


int k,m,n,sum;
int num[101][101];
int main()
{
    int i,j,l;
    cin>>k;
    for(i=0;i<k;++i)
    {
            memset(num,0,sizeof(num));
            sum=0;
            cin>>m>>n;
            for(j=0;j<m;++j)
            {
                    for(l=0;l<n;++l)
                    {
                            cin>>num[j][l];
                    }
            }
            for(j=0;j<n;++j) sum+=num[0][j]+num[m-1][j];
            for(j=1;j<m-1;++j) sum+=num[j][0]+num[j][n-1];
            cout<<sum<<endl;
    }
    return 0;
}


int main() {
	int k,m,n;
	int i,j,t;
	int sum;
	int z;
	scanf("%d",&k);
	for(t=0;t<k;t++) {
		scanf("%d%d",&m,&n);
		sum=0;
		for(i=0;i<m;i++) {
			for(j=0;j<n;j++) {
				scanf("%d",&z);
				if(i==0 || i==m-1) sum+=z;
				else {
					if(j==0 || j==n-1) sum+=z;
				}
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}


const int M = 100 + 10;
const int N = 100 + 10;
int mat[M][N];
int main(void) {
	int cases, i, j, ans, m, n;
	scanf("%d", &cases);
	while (cases--) {
		ans = 0;
		scanf("%d%d", &m, &n);
		for (i = 0; i < m; ++i) {
			for (j = 0; j < n; ++j) {
				scanf("%d", mat[i] + j);
			}
		}
		if (m == 0 || n == 0) {
			printf("%d\n", 0);
			continue;
		}
		if (m == 1) {
			for (i = 0; i < n; ++i) {
				ans += mat[0][i];
			}
			printf("%d\n", ans);
			continue;
		} else if (n == 1) {
			for (i = 0; i < m; ++i) {
				ans += mat[i][0];
			}
			printf("%d\n", ans);
			continue;
		}

		for (i = 0; i < n; ++i) {
			ans += mat[0][i];
			ans += mat[m - 1][i];
		}
		for (i = 0; i < m; ++i) {
			ans += mat[i][0];
			ans += mat[i][n - 1];
		}
		ans -= (mat[0][0] + mat[0][n - 1] + mat[m - 1][0] + mat[m - 1][n - 1]);
		printf("%d\n", ans);
	}
	return 0;
}


int main()
{
	int n;
	scanf("%d",&n);
	int i = 1;
	for(i;i<=n;i++)
	{
		int p,q;
		scanf("%d %d",&p,&q);
		int a[10000];
for(int j = 0;j<p*q;j++)
scanf("%d",&a[j]);
		int sum = 0;
		int m=0;
		while(m<q)
		{
			sum = sum + a[m];
			m++;
		}
		m = (p - 1) * q ;
		while(m<p*q)
		{
			sum = sum + a[m];
			m++;
		}
		m = 1;
		while(m<p-1)
		{
			sum = sum + a[q*m];
			m++;
		}
		m = 2;
		while(m<p)
		{
			sum = sum +a[q*m-1];
			m++;
		}
		printf("%d\n",sum);
	}
	return 0;
}


int main (){
   int rie,k,i;
   int ROW,COL;
   int row,col;
   int sz[100][100]={0};
   int sum[100];

   scanf("%d",&k);

   for(i=1;i<=k;i++){
      scanf("%d%d",&ROW,&COL);
      for(row=0;row<ROW;row++){
         for(col=0;col<COL;col++){
             scanf("%d",&(sz[row][col]));
         }
      }
      rie=0;
      for(col=0;col<=COL-1;col++){
                 rie+=sz[0][col];
      }for(row=1;row<=ROW-1;row++){
                 rie+=sz[row][COL-1];
      }for(col=COL-2;col>=0;col--){
                 rie+=sz[ROW-1][col];
      }for(row=ROW-2;row>=1;row--){
                 rie+=sz[row][0];
      }sum[i]=rie;
   }

    for(i=1;i<=k;i++){
       printf("%d\n",sum[i]);
    }
	return 0;
}


int main()
{
	int i=0,j=0,k=0,shuzu[100][100],hang=0,lie=0,zu=0,sum=0;
	scanf("%d",&zu);
	for(i=0;i<zu;i++)
	{
		scanf("%d%d",&hang,&lie);
		sum=0;
		for(j=0;j<hang;j++)
		{
			for(k=0;k<lie;k++)
			{
				scanf("%d",&shuzu[j][k]);
			}
		}
		for(k=0;k<lie;k++)
		{
			sum=sum+shuzu[0][k];
		}
		if(hang>1)
		{
			for(k=0;k<lie;k++)
			{
				sum=sum+shuzu[hang-1][k];
			}
		}
		if(hang>2)
		{
			for(k=1;k<hang-1;k++)
			{
				sum=sum+shuzu[k][0];
			}
		}
		if(lie>1&&hang>2)
		{
			for(k=1;k<hang-1;k++)
			{
				sum=sum+shuzu[k][lie-1];
			}
		}
		printf("%d\n",sum);

	}
	return 0;
}


int main()
{
	int k,n,m,num[100][100],sum;
	cin>>k;
	cout<<endl;
	for(int a=0;a<k;a++)
		{   cin>>m>>n;
	          sum=0;
			for(int i=0;i<m;i++)
	       {
		       for(int j=0;j<n;j++)
		          { cin>>num[i][j];
			        cout<<" ";
			   if(i==0||i==m-1||j==0||j==n-1)
			   { sum+=num[i][j];}
			   }
			   cout<<endl;
			}
			cout<<sum<<endl;
	}
			return 0;
}


/*
 * linofjuz.cpp
 *
 *  Created on: 2011-12-25
 *      Author: Administrator
 */

int main()
{
	int n;int a,b;
	int juzhen[100][100];
	cin>>n;
	for(int m=1;m<=n;m++)
	{
		cin>>a>>b;
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				cin>>*(*(juzhen+i)+j);
		int s=0;
		for(int i=0;i<b;i++)
		{
			s=juzhen[0][i]+s;
			s=juzhen[a-1][i]+s;
		}
		for(int j=1;j<a-1;j++)
		{
			s=juzhen[j][0]+s;
			s=juzhen[j][b-1]+s;
		}
		cout<<s<<endl;
	}
}


int main()
{
    int n;
    int p,q;
    int tmp;
    scanf("%d",&n);
    while(n--)
    {
        int res=0;
        scanf("%d%d",&p,&q);
        for(int i=0;i<p;i++)
            for(int j=0;j<q;j++)
            {
                scanf("%d",&tmp);
                if(i==0||j==0|i==p-1||j==q-1)
                    res+=tmp;
            }
        printf("%d\n",res);
    }
    return 0;
}


int summer();

int main(void)
{
    int counter,times,patty;
    scanf("%d",&times);

    for(counter=0;counter<times;counter++)
    {
    patty=summer();
    printf("%d\n",patty);
    }

    return 0;
}

int summer()
{
    int m,n;
    int line,row;

    scanf("%d%d",&line,&row);
    int fib[SIZE][SIZEE];

    for(m=0;m<line;m++)
    {
                    for(n=0;n<row;n++)
                    {
                                    scanf("%d",&fib[m][n]);
                    }
    }
    int sum=0;
    int i;
    for(i=0;i<row;i++)
    {
                      sum=sum+*((*fib)+i)+*(*(fib+line-1)+i);
    }

    for(i=1;i<line-1;i++)
    {
                        sum=sum+*(*(fib+i))+*(*(fib+i)+row-1);
    }

    return sum;
}


int main()
{
    int n,i;

    cin >> n;
    for (i=0;i<=n-1;i++)
    {
        int row,col;
        cin >> row >> col;
        int number[100][100];

        int k,m;
        for (k=0;k<=row-1;k++)
        {
            for (m=0;m<=col-1;m++)
            {
                cin >> number[k][m];
            }
        }
        int sum=0;
        for (k=0;k<=row-1;k++)
        {
            for (m=0;m<=col-1;m++)
            {
                if (k==0||m==0||k==row-1||m==col-1)
                {
                    sum+=number[k][m];
                }
            }
        }
        cout << sum << endl;
    }

    return 0;
}


int main ()
{
 int a,k,i,j,row,col;
 int sx_row,sx_col,s;
 scanf("%d",&k);
 for(a=0;a<k;a++)
 {
s=0;
scanf("%d %d",&row,&col);
     int sz[100][100];
     for(i=0;i<row;i++)
  {
      for(j=0;j<col;j++)
   {
       scanf("%d",&sz[i][j]);
   }
  }
     sx_row=row-1;
     sx_col=col-1;
  for(j=0;j<sx_col;j++)
  {
   s=s+sz[0][j];
  }
  for(i=0;i<sx_row;i++)
  {
   s=s+sz[i][sx_col];
  }
  for(j=sx_col;j>0;j--)
  {
   s=s+sz[sx_row][j];
  }
  for(i=sx_row;i>0;i--)
  {
   s=s+sz[i][0];
  }
  printf("%d\n",s);
 }
 return 0;
}


int main()
{
    int sz[100][100];
    int m,n,k,x;
    x=0;
    scanf("%d",&k);
    for(int i=0;i<k;i++)
    {
    scanf("%d %d",&m,&n);
    for(int row=0;row<m;row++)
    {
            for(int col=0;col<n;col++)
            {
                    scanf("%d",&sz[row][col]);
            }
    }
    for(int row=0;row<m;row++)
    {
            x+=sz[row][0];
    }
    for(int col=1;col<n;col++)
    {
            x+=sz[0][col];
    }
    for(int row=1;row<m;row++)
    {
            x+=sz[row][n-1];
    }
    for(int col=1;col<n-1;col++)
    {
            x+=sz[m-1][col];
    }
    printf("%d\n",x);
    x=0;
    }
return 0;
}


int main()
{
	int a[100][100],times,x,y,i,j,k,sum=0;
	int *pointer=NULL;
	cin>>times;
	for(i=1;i<=times;i++)
	{
		sum=0;
		cin>>x>>y;
		for(k=0;k<x;k++)
		{
			for(j=0;j<y;j++)
			{
				cin>>a[k][j];
				pointer=&a[k][j];
				if(k==0||j==0||k==x-1||j==y-1)
				   sum=sum+*pointer;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}


/*
 * jisuanjuzhenbianyuan.cpp
 *
 *  Created on: 2011-1-8
 *      Author: qaj
 */
int main(){
	int num;
	cin>>num;
	for(int z=0;z<num;z++){
		int a,b;
		cin>>a>>b;
		int juzhen[100][100];
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				cin>>juzhen[i][j];
		int sum=0;
		for(int i=0;i<b;i++)
			sum=sum+juzhen[0][i];
		for(int j=1;j<a-1;j++){
			sum=sum+juzhen[j][0];
			sum=sum+juzhen[j][b-1];
		}
		for(int i=0;i<b;i++)
			sum=sum+juzhen[a-1][i];
		cout<<sum<<endl;
	}
	return 0;

}


//
//  main.cpp
//  Homework
//  Xcode Version 5.0.2 (5A3005)
//  OS X Version 10.9 (13A603)
//  Created by ??? on 13-12-4.
//  Copyright (c) 2013? ???. All rights reserved.
//

int main()
{
    int t;
    cin>>t;
    for(int time=0;time<t;time++)
    {
        int m,n,sum=0;
        cin>>m>>n;
        int a[m][n];
        for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
                cin>>*(*(a+i)+j);
        for(int i=0;i<n;i++)
            sum+=*(*a+i)+(n>1)**(*(a+m-1)+i);
        for(int i=1;i<m-1;i++)
            sum+=*(*(a+i))+(m>1)**(*(a+i)+n-1);
        cout<<sum<<endl;
    }
    return 0;
}


int main(){
	int k,jz[100][100],ROW,COL,h[100],y,i,row,col;
	scanf("%d",&k);
	for(i=0;i<k;i++){
		scanf("%d%d",&ROW,&COL);
		for( row = 0; row < ROW; row++){
			for( col = 0; col < COL; col++){
					scanf("%d",&jz[row][col]);
		}}
			y=0;
		    for(row = 0; row < ROW; row++){
					y+=jz[row][0];

			}
			for(row = 0; row < ROW; row++){
					y+=jz[row][COL-1];
			}

            for(col= 0; col< COL; col++){
					y+=jz[0][col];
			}
            for(col= 0; col< COL; col++){
					y+=jz[ROW-1][col];
			}

			h[i]=y-jz[0][0]-jz[0][COL-1]-jz[ROW-1][0]-jz[ROW-1][COL-1];
	 	}
	for(i=0;i<k;i++){
	        printf("%d\n",h[i]);

	}return 0;
	}


/*
 * 12-4.cpp
 *
 *  Created on: 2011-12-25
 *      Author: sony
 */

int main()
{
    int k, m, n;
    cin >> k;
    int u;
    for (u = 1; u <= k; u++) {
        int i, j;
        cin >> m >> n;
        int input[m][n];
        for (i = 0; i < m; i++) {
            for (j = 0; j < n; j++) cin >> input[i][j];
        }
        int sum = 0;
        for (i = 0; i < m; i++) {
            sum += input[i][0] + input[i][n - 1];
        }
        for (j = 0; j < n; j++) {
            sum += input[0][j] + input[m - 1][j];
        }
        sum = sum - input[0][0] - input[0][n - 1] - input[m - 1][0] - input[m - 1][n - 1];
        cout << sum << endl;
    }
	return 0;
}


int main()
{
int k;
scanf("%d",&k);
while(k--)
{
int m,n;
scanf("%d %d",&m,&n);
int a[101][101];
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
scanf("%d",&a[i][j]);
int sum=0;
for(int i=0;i<m;i++)
sum=sum+a[i][0]+a[i][n-1];
for(int i=1;i<n-1;i++)
sum=sum+a[0][i]+a[m-1][i];
printf("%d\n",sum);
}
return 0;
}


int main()
{
    int K,M,N,sz[99][99];
    scanf("%d",&K);
    for(int k=1;k<=K;k++)
    {
        int result=0;
        scanf("%d %d",&M,&N);
        for(int m=0;m<M;m++) for(int n=0;n<N;n++) scanf("%d",&sz[m][n]);
        if(M<=2||N<=2)
        {
            for(int m=0;m<M;m++) for(int n=0;n<N;n++) result+=sz[m][n];
        }
        else
        {
            for(int n=0;n<N;n++) result+=sz[0][n];
            for(int n=0;n<N;n++) result+=sz[M-1][n];
            for(int m=1;m<M-1;m++) result+=sz[m][0];
            for(int m=1;m<M-1;m++) result+=sz[m][N-1];
        }
        printf("%d\n",result);
    }
    return 0;
}


int main(){
    int k,i,j;
    int n,row,col;
    int shuzu[mx][mx],cc[1000]={99};
    int result=0;

    scanf("%d",&n);
    for(k=0;k<n;k++){
       scanf("%d %d",&row,&col);
       for(i=0;i<row;i++){
          for(j=0;j<col;j++){
            scanf("%d",&shuzu[i][j]);
          }
       }
      for(i=0;i<row;i++){
          for(j=0;j<col;j++){
            if(i==0){result+=shuzu[i][j];}
              else if(i==(row-1)){result+=shuzu[i][j];}
            else{if(j==0){result+=shuzu[i][j];}
              else if(j==(col-1)){result+=shuzu[i][j];}
         }
          }
       }
       cc[k]=result;
       result=0;

   }

    for(k=0;k<n;k++){
      printf("%d\n",cc[k]);
    }

    return 0;
}


int main()
{
	int n=0,row=0,line=0,l=0;
	int Matrix[100][100]={{0},{0}};
	int a = 0, b = 0, c = 0, d = 0;
	int total = 0,extra = 0;
	scanf("%d",&n);
	while (l < n)
	{
		scanf("%d %d", &row, &line);
		for (int i = 0; i < row; i ++)
			for(int j = 0; j < line; j ++)
				scanf("%d", &Matrix[i][j]);
		if(row == 1|| line ==1)
			for(int i=0;i<row;i++)
				for(int j=0;j<line;j++)
					total+=Matrix[i][j];
		else
		{
			extra = Matrix[0][0] + Matrix[0][line-1] + Matrix[row-1][0] + Matrix[row-1][line-1];
			for (int i = 0; i < line; i ++)
			{
				a += Matrix[0][i];
				c += Matrix[row-1][i];
			}
			for (int i = 0; i < row; i ++)
			{
				b += Matrix[i][0];
				d += Matrix[i][line-1];
			}
			total = a + b + c + d - extra;
		}
			printf("%d\n", total);
			l ++;
			a = 0;b = 0;c = 0;d = 0;
	}
	return 0;
}


int main()
{
int t,m,n,count;
int a[100][100];
cin >> t;
for(int temp = 0 ; temp < t ; temp++)
{
	count = 0;
	cin >> m >> n;
	for(int i = 0 ; i < m; i++)
		for(int j = 0 ; j < n; j++)
			cin >> a[i][j];
	for(int i = 1 ; i < m-1; i++)
	{
		count += a[i][0];
		count += a[i][n-1];
	}//cout << count << endl;
	for(int j = 0 ; j < n; j++)
	{
		count += a[0][j];
		count += a[m-1][j];
	}
	cout << count << endl;
}
return 0;
}


/*
 * SumOfEdgeElements.cpp
 *
 *  Created on: 2012-12-11
 *      Author: Cui Zhaoxiong Class4 1200012931
 */
int sum = 0;
int m, n;
void Input(int(*a)[102]) {
	cin >> m >> n;
	for (int i = 0; i <= m - 1; i++) {
		for (int j = 0; j <= n - 1; j++) {
			cin >> *(*(a + i) + j);
		}
	}
}
void Sum(int x, int y, int(*a)[102]) {//????
	sum += *(*(a + x) + y);
	if (x == 0 && y < n - 1)
		Sum(x, y + 1, a);
	else if (x < m - 1 && y == n - 1)
		Sum(x + 1, y, a);
	else if (x == m - 1 && y > 0)
		Sum(x, y - 1, a);
	else if (y == 0 && x > 1)
		Sum(x - 1, y, a);
	else
		return;
}
int main() {
	int a[102][102];
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		sum = 0;
		Input(a);
		Sum(0, 0, a);
		if (i != 1)
			cout << endl;
		cout << sum;
	}
	return 0;
}


int main()
{
int n;
cin>>n;
for(int k=1;k<=n;k++)
{
	int row,col,count=0,i,j;
	cin>>row>>col;
	int str[101][101];
	for(i=1;i<=row;i++)
	  for(j=1;j<=col;j++)
	     {
		 cin>>*(*(str+i)+j);                                                  //????
		 }
	for(i=1;i<=col;i++)
	   count=count+*(*(str+1)+i);
	for(i=2;i<=row;i++)
	   count=count+*(*(str+i)+col);                                          //???????count
	for(i=col-1;i>=1;i--)
	   count=count+*(*(str+row)+i);
	for(i=row-1;i>=2;i--)
	   count=count+*(*(str+i)+1);
	cout<<count<<endl;                                                      //??
}
return 0;
}


int main(){

	int n=0;

	cin>>n;

	int result[100];

	for(int i=0;i<n;i++){

		int x=0;
		int y=0;

		cin>>x>>y;

		int r[100][100];

		for(int j=0;j<x;j++){
			for(int k=0;k<y;k++){
				cin>>r[j][k];
			}
		}

		result[i]=0;

		for(int j=0;j<x;j++){
			if(j==0||j==x-1){

				for(int k=0;k<y;k++){
					result[i]+=r[j][k];
				}

			}
			else{
			result[i]+=r[j][0];
			result[i]+=r[j][y-1];
			}
		}

	}

	for(int i=0;i<n;i++){
		cout<<result[i];
		if(i<n-1) cout<<endl;
	}

	return 0;

}


int num,n,m,a[100][100];
int main()
{   cin>>num;
    for(int x=0;x<num;x++)
    {       cin>>m>>n;
            for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
            cin>>a[i][j];
            int ans=0;
            for(int i=0;i<m;i++)
            ans+=a[i][0]+a[i][n-1];
            for(int i=1;i<n-1;i++)
            ans+=a[0][i]+a[m-1][i];
            cout<<ans<<endl;
    }
    getchar();getchar();
    return 0;
}


int main()
{
	int k=0;
	cin>>k;
	int m=0,n=0;
	while(cin>>m>>n)
	{
		int result=0;
		int num[100][100]={0};
		int i,j;
		for(i=0;i<m;i++)
			for(j=0;j<n;j++)
			cin>>num[i][j];
		for(j=0;j<n;j++)
			result+=num[0][j]+num[m-1][j];
		for(i=1;i<(m-1);i++)
			result+=num[i][0]+num[i][n-1];
		cout<<result<<endl;
	}
	return 0;
}


int main()
{
    int t;
    cin>>t;
    for(int i = 0 ; i < t ; i++)
    {
            int n,m;
            cin>>m>>n;
            int num[110][110];
            for(int j = 0 ; j < m ; j++)
                    for(int k = 0 ; k < n ; k++)cin>>num[j][k];
            int sum=0;
			if(m==1 && n!=1)
		{
				for(int j = 0 ; j < n ; j++)sum=sum+num[0][j];
				cout<<sum<<endl;
		}
		else if(m!=1 && n==1)
	{
			for(int j = 0 ; j < m ; j++)sum=sum+num[m][0];
			cout<<sum<<endl;
	}
            else if(m==1 && n==1)cout<<num[0][0]<<endl;
			else
		{for(int j = 0 ; j < n ; j++)sum=sum+*(*num+j);
            for(int j = 0 ; j < n ; j++)sum=sum+*(num[m-1]+j);
            for(int j = 1 ; j < m-1 ; j++)sum=sum+**(num+j);
            for(int j = 1 ; j < m-1 ; j++)sum=sum+*(*(num+j)+n-1);
            cout<<sum<<endl;
		}
    }    return 0;
}


int main()
{
	int k;
	cin >>k;
	for (int i=0;i<k;i++)
	{
		int m,n,board[100][100],sum=0;
		int (*p)[100];
		cin >>m >>n;
		for (int j=0;j<m;j++)
          for (int p=0;p<n;p++)
			cin >>board[j][p];
		for (int j=0;j<m;j++)
          for (int p=0;p<n;p++)
		  {
			  if (j==0||j==m-1||p==0||p==n-1)
				sum+=board[j][p];
		  }
		  cout <<sum <<endl;
	}

	return 0;
}


/*
 * 12-4.cpp
 *
 *  Created on: 2011-12-25
 *      Author: sony
 */

int main()
{
    int k, m, n;
    cin >> k;
    int u;
    for (u = 1; u <= k; u++) {
        int i, j;
        cin >> m >> n;
        int input[m][n];
        int (*p)[n] = input;
        for (i = 0; i < m; i++) {
            for (j = 0; j < n; j++)  cin >> *(*(p + i) + j);        //cin >> input[i][j];
        }
        int sum = 0;
        for (i = 0; i < m; i++) {
            sum += input[i][0] + input[i][n - 1];
        }
        for (j = 0; j < n; j++) {
            sum += input[0][j] + input[m - 1][j];
        }
        sum = sum - input[0][0] - input[0][n - 1] - input[m - 1][0] - input[m - 1][n - 1];
        cout << sum << endl;
    }
	return 0;
}


int m[100][100];
void a()
{
	memset(m,0,sizeof(m));
	int x,y,count=0,sum=0;
	cin>>x>>y;
	int *p=m[0];
	for(;p<=m[x-1]+y-1;p++)
	{
		count++;
		cin>>*p;
		if(count==1||count==y)
			sum+=*p;
		else if(p<=m[0]+y-1)
			sum+=*p;
		else if(m[x-1]<=p&&p<=m[x-1]+y-1)
			sum+=*p;
		if(count==y)
		{
			p=p+100-y;
			count=0;
		}
	}
	cout<<sum<<endl;
}
int main()
{
	int k,i;
	cin>>k;
	for(i=0;i<k;i++)
	{
		a();
	}
	return 0;
}


int main()
{
	int n,hang,lie,h,*p,i,j,a[10000],place;
	int sum=0;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		sum=0;
		scanf("%d%d\n",&hang,&lie);
		p=a;
		for (j=1;j<=hang;j++)
		{
			for (h=1;h<=lie;h++)
			{
				scanf("%d",&*(p++));
			}

		}
		for (place=0;place<=lie-1;place++)
		{
			p=a+place;
			sum+=*p;
		}
		for (place=2*lie-1;place<hang*lie-1;place+=lie)
		{
			p=a+place;
			sum+=*p;
		}
		for (place=hang*lie-1;place>hang*lie-lie;place--)
		{
			p=a+place;
			sum+=*p;
		}
		for (place=lie;place<=hang*lie-lie;place+=lie)
		{
			p=a+place;
			sum+=*p;
		}

		printf("%d\n",sum);
	}
}


int main() {
	int n, a[100][100], row, col, sum = 0;
	cin >> n;
	for(int i = 0; i < n; i ++){
		sum = 0;
		cin >> row >> col;
		for(int i = 0; i < row; i ++)
			for(int j = 0; j < col; j ++)
				cin >> a[i][j];
		if(row == 1 && col == 1) cout <<*(a[0]);
		else {
		for(int i = 0; i < col; i ++){
			sum += *(a[0] + i);
			sum += *(a[row-1] + i);
		}
		for(int j = 1; j <row-1; j ++){
			sum += *(a[j]);
			sum += *(a[j]+col-1);
		}
		cout << sum <<endl;
	}
	}
	return 0;
}


int map[100][100];
int m,n;
void count()
{
    int i,j;
    int sum=0;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i+j==j||i+j==i||i+j==i+n-1||i+j==j+m-1)
            {
                sum=sum+map[i][j];
            }
        }
    }
    cout<<sum<<endl;
}
int main()
{
    int sum;int k=0;
    cin>>sum;
    int i,j;
    for(k=0;k<sum;k++)
    {
        cin>>m>>n;
        for(i=0;i<m;i++)
        {
            for(j=0;j<n;j++)
            {
                cin>>map[i][j];
            }
        }
        count();
    }
}


int main()
{
	int k,m,n,i,j,h,a[1000][1000]={0},result;
	cin>>k;
	for(h=0;h<k;h++)
	{
		result=0;
		cin>>m>>n;
		for(i=0;i<m;i++)
			for(j=0;j<n;j++)
				cin>>a[i][j];
		for(j=0;j<n;j++)
			result=result+a[0][j]+a[m-1][j];
		for(i=1;i<m-1;i++)
			result=result+a[i][0]+a[i][n-1];
		cout<<result<<endl;
	}
	return 0;
}


int main()
{
	int x;
	cin>>x;
	int sum=0;
	int m,n;

	int g,i,j,temp;
	for(g=0;g<x;g++)
	{
		cin>>m;
		cin>>n;
		sum=0;
		for(i=0;i<n;i++)
		{
			cin>>temp;
			sum+=temp;
		}

		for(i=0;i<m-2;i++)
		{
			for(j=0;j<n;j++)
			{
				cin>>temp;
				if(j==0 || j==n-1)
				{
					sum+=temp;
				}
			}
		}
		if(m!=1)
		{
			for(i=0;i<n;i++)
			{
				cin>>temp;
				sum+=temp;
			}
		}
		cout<<sum<<endl;
	}
	return 0;

}


int main()
{
	int number[100][100];
	int k,i,x,y;
	int m,n;
	cin>>k;
	for(i=0;i<k;i++)
	{
		int sum=0;
		cin>>m>>n;
		for(x=0;x<m;x++)
		{
			for(y=0;y<n;y++)
			{
				cin>>*(*(number+x)+y);
			}
		}
		if(n==1&&m==1)
			cout<<**number<<endl;
		else
		{
			for(x=0;x<m;x++)
			{
				sum+=*(*(number+x));
				sum+=*(*(number+x)+n-1);
			}
			//cout<<sum<<endl;

			for(y=0;y<n;y++)
			{
				sum+=*(*(number)+y);
				sum+=*(*(number+m-1)+y);
			}
			//cout<<sum<<endl;
			sum=sum-*(*(number))-*(*(number)+n-1)-*(*(number+m-1))-*(*(number+m-1)+n-1);
			cout<<sum<<endl;
		}
	}
	return 0;
}


void main()
{
	int n=0;
	int i=0,j=0,k=0;
	int row,col;
	int str[100][100]={0};
	int sum;
	scanf("%d",&n);
	for(;i<n;i++)
	{
		sum=0;
		scanf("%d%d",&row,&col);
		for(j=0;j<row;j++)
			for(k=0;k<col;k++)
				scanf("%d",&str[j][k]);
		for(j=0;j<col;j++)
			sum+=str[0][j]+str[row-1][j];
		for(j=1;j<row-1;j++)
			sum+=str[j][0]+str[j][col-1];
		printf("%d\n",sum);
	}
}


int main()
{
	int num , ii , m , n , i , j , str[ 111 ][ 111 ] , total ;

	cin >> num ;

	for( ii = 1 ; ii <= num ; ii ++ )
	{
		cin >> m >> n ;

		for( i = 0 ; i < m ; i ++ )
			for( j = 0 ; j < n ; j ++ )
				cin >> str[ i ][ j ] ;

		total = 0 ;

		for( i = 0 ; i < n ; i ++ )
			total = total + *( *str + i ) ; //???

		for( i = 0 ; i < n ; i ++ )
			total = total + *( *( str + m - 1 ) + i ) ; //?m?

		for( i = 1 ; i < m - 1 ; i ++ )
			total = total + **( str + i ) ; //???

		for( i = 1 ; i < m - 1 ; i ++ )
			total = total + *( *( str + i ) + n - 1 ) ; //???

		cout << total << endl ;

	}

	return 0 ;
}


int main()
{
	int i,j,sum,m,n,k;		//k cases,m rows,n columns;
	int a[MAX_LEN][MAX_LEN];
	cin >> k;
	while (k--)
	{
		cin >> m >> n;
		for (i=0;i<m;i++)
			for (j=0;j<n;j++)
				cin >> a[i][j] ;
		for (sum=i=0;i<m;i++)				//the first column and the last column
			sum=sum+a[i][0]+a[i][n-1];
		for (j=1;j<n-1;j++)
			sum=sum+a[0][j]+a[m-1][j];		//the first row and the last row(not including corner)
		cout << sum << endl;
	}
	return 0;
}


int calcSum(int *matrix, int row, int col);
int main()
{
	int k;
	scanf("%d", &k);
	int *result = (int *)malloc(k * sizeof(int));
	int i = 0;
	int row ,col;
	int sum;
	int m, n;
	int *matrix;
	for (i = 0; i < k; i++)
	{
		scanf("%d %d", &m, &n);
		matrix = (int *)malloc(m * n * sizeof(int));
		for (row = 0; row < m; row++)
			for (col = 0; col < n; col++)
				scanf("%d", matrix + row * n + col);
		 *(result + i) = calcSum(matrix, m, n);
		free(matrix);
	}
	for (i = 0; i < k - 1; i++)
	{
		printf("%d\n", *(result + i));
	}
	printf("%d", *(result + i));
	return 0;
}

int calcSum(int *matrix, int row, int col)
{
	int sum = 0;
	int i, j;
	for (i = 0; i < row; i++)
		for (j = 0; j < col; j++)
		{
			if (i == 0 || i == row - 1 || j == 0 || j == col - 1)
				sum += *(matrix + i * col + j);
		}
	return sum;
}


void m(int,int);
main()
{
	int a,b,c,i;
	scanf("%d",&a);
	for(i=0;i<a;i++)
	{
		scanf("%d%d",&b,&c);
		m(b,c);
	}
}
void m(int q,int w)
{
	int a,i,j;
	long sum;
	sum=0;
	for(i=1;i<=q;i++)
	{
		for(j=1;j<=w;j++)
		{
			scanf("%d",&a);
			if(i==1||j==1||i==q||j==w)
			{
				sum+=a;
			}
		}
	}
	printf("%ld\n",sum);
}


int f(int *p,int m,int n)
{
	int row,col,temp,sum=0;
	for(row=1;row<m+1;row++)
	{
		for(col=1;col<n+1;col++)
		{
			if(row==1 || row==m || col==1 || col==n)
			{
				temp=*(p+n*(row-1)+col);
				sum+=temp;
			}
		}
	}
	return sum;
}
int main()
{
	int k,m,n,i,s,row,col;
	int *p;
	p=(int *)malloc(sizeof(int));
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d %d",&m,&n);
		for(row=1;row<m+1;row++)
		{
			for(col=1;col<n+1;col++)
			{
				scanf("%d",p+n*(row-1)+col);
			}
		}
		s=f(p,m,n);
		printf("%d\n",s);
	}
	return 0;
}


void sub(void)
{
	int m,n;
	scanf("%d %d",&m,&n);
	int *p;
	int i,sum=0;
	p=(int*)malloc(10000*sizeof(int));
	for(i=0;i<m*n;i++)
		scanf("%d",p+i);
	for(i=1;i<n-1;i++) sum=sum+*(p+i);
	for(i=m*n-n+1;i<m*n-1;i++)  sum=sum+*(p+i);
	for(i=0;i<m*n;i++)
		if((i%n)==0||((i+1)%n)==0) sum=sum+*(p+i);
	printf("%d\n",sum);
}

void main()
{
	int k;
	scanf("%d",&k);
	int i;
	for(i=0;i<k;i++)
	sub();
}


void input( int a[][100] , int m , int n )
{
	for ( int i = 0 ; i < m ; i++ )
		for ( int j = 0 ; j < n ; j++ )
			cin >> * ( * ( a + j ) + i ) ;
}
int main()
{
	int square[100][100] ;
	int k , m , n ;
	cin >> k ;
	for ( int i = 1 ; i <= k ; i++ )
	{
		cin >> m >> n ;
		input( square , m , n ) ;
		int sum = 0 ;
		for ( int j = 0 ; j < m ; j++ )
			sum = sum + * ( * square + j ) + * ( * ( square + n - 1 ) + j ) ;
		for ( int j = 1 ; j < n - 1 ; j++ )
			sum = sum + * * ( square + j ) + *( * ( square + j ) + m - 1 ) ;
		if ( m == 1 )
			sum = sum / 2 ;
		cout << sum << endl ;
	}
	return 0 ;
}
// ( > w < ) finished~


int main(){
	int a[ROW][COL];
	int s=0;
	int m,n,k;
	scanf("%d",&k);

	for(int t=1;t<=k;t++){
	    scanf("%d %d",&m,&n);
		for(int q=0;q<m;q++){
			for(int p=0;p<n;p++){
                scanf("%d",&a[q][p]);
			}
		}
	    int col=0,row=0;
	    for(col;col<n;col++){
		    s=s+a[row][col];
		}
	    col=0;
	    for(row;row<m;row++){
		    s=s+a[row][col];
		}
		row=m-1;
		col=0;
	    for(col;col<n;col++){
		    s=s+a[row][col];
		}
	    col=n-1;
		row=0;
	    for(row;row<m;row++){
		    s=s+a[row][col];
		}
	    s=s-a[0][0]-a[m-1][n-1]-a[0][n-1]-a[m-1][0];
	    printf("%d\n",s);
		s=0;
	}
	return 0;
}


/*
 * bianyuanshuzizhihe.cpp
 *
 *  Created on: 2012-12-13
 *      Author: Lenovo
 */
int main()
{
	int array[100][100];
	int n,sum,row,col;
	int *point;
	point = *array;
	cin>>n;
	for(;n>0;n--)
	{
		sum = 0;
		cin>>row>>col;
		for(point = *array;point<*array + row*col;point++)
			cin>>*point;
		point = *array;
		for(;point<*array+col;point++)
		{
			sum = sum+*point;
		}
		point--;
		for(point=point+col;point<*array + row*col;point=point+col)
		{
			sum = sum+*point;
		}
		point-=col;
		for(point=point-1;point>=*array+ (row-1)*col;point--)
			sum = sum+*point;
		point++;
		for(point=point-col;point>*array;point = point - col)
			sum = sum+*point;
		cout<<sum<<endl;
	}
	return 0;
}


int main(){
int k,i,e;
scanf("%d",&k);
for(i=0;i<k;i++){
int a,b,c,d,total;
scanf("%d%d",&a,&b);
if(a==1&&b==1){
scanf("%d",&c);
printf("%d",c);
}else{
int sz[a][b];
for(c=0;c<a;c++){
for(d=0;d<b-1;d++){
scanf("%d",&sz[c][d]);
}
scanf("%d\n",&sz[c][b-1]);
}
total=0;
for(c=0;c<a;c++){
total=total+sz[c][0];
total=total+sz[c][b-1];
}
for(c=0;c<b;c++){
total=total+sz[0][c];
total=total+sz[a-1][c];
}
total=total-sz[0][0];
total=total-sz[0][b-1];
total=total-sz[a-1][0];
total=total-sz[a-1][b-1];
printf("%d\n",total);
}
}
return 0;
}


int main()
{
	int count,m,n,array[100][100],sum[100]={0},i,j,p;
	scanf("%d",&count);
	for(i=0;i<count;i++)
	{
		scanf("%d%d",&m,&n);
		for(j=0;j<m;j++)
			for(p=0;p<n;p++)
				scanf("%d",&array[j][p]);
		for(j=0;j<n;j++)
		{
			sum[i]=sum[i]+array[0][j];
			if(m>1)
			sum[i]=sum[i]+array[m-1][j];
		}
		for(j=1;j<m-1;j++)
		{
			sum[i]=sum[i]+array[j][0];
			sum[i]=sum[i]+array[j][n-1];
		}
	}
	for(i=0;i<count;i++)
	printf("%d\n",sum[i]);
    return 0;
}


void main()
{
	int bysum(int z);
	int k;
	scanf("%d",&k);
	int *m,*n;
	m=(int*)malloc(k*sizeof(int));
	for(n=m;n<m+k;n++)
		printf("%d\n",bysum(*n));
}
int bysum(int z)
{
	int m,n,*a,*b,sum=0;
	scanf("%d%d",&m,&n);
    a=(int*)malloc(m*n*sizeof(int));
    for(b=a;b<a+m*n;b++)
		scanf("%d",b);
    for(b=a;b<a+n;b++)
		sum=sum+*b;
    for(b=a+(m-1)*n;b<a+m*n;b++)
		sum=sum+*b;
    for(b=a+n;b<a+(m-2)*n+1;b=b+n)
        sum=sum+*b;
	for(b=a+n*2-1;b<a+(m-2)*n+n;b=b+n)
	    sum=sum+*b;
	return(sum);
}


int main()
{
 	int n;
 	scanf("%d",&n);
 	fflush(stdin);

 	int i,j,k,m;
 	int lie,h;
 	int sum1=0,sum2=0,sum3=0,sum4=0,sum=0;
 	//int matrix[100][100];

 	for(i=0;i<n;i++)
 	{
		sum1=0,sum2=0,sum3=0,sum4=0,sum=0;
		scanf("%d%d",&h,&lie);
		int matrix[h][lie];
		//printf("%d %d",h,lie);

		for(j=0;j<h;j++)
		for(k=0;k<lie;k++)
		{
			scanf("%d",&matrix[j][k]);
		}
		fflush(stdin);

		if(h==1&&lie==1)
		{
			printf("%d\n",matrix[0][0]);
			return 0;
			}

	    for(m=0;m<lie;m++)
	    {
			sum1+=matrix[0][m];
			sum2+=matrix[h-1][m];
		}

		for(m=0;m<h;m++)
	    {
			sum1+=matrix[m][0];
			sum2+=matrix[m][lie-1];
		}

		sum=sum1+sum2+sum3+sum4-(matrix[0][0]+matrix[0][lie-1]+matrix[h-1][0]+matrix[h-1][lie-1]);

		printf("%d\n",sum);

	}
			return 0;
	}


int main()
{
	int num_data;
	cin>>num_data;
 	while(num_data--)
	{
		int a[100][100];
		int m,n;
		int sum=0;

		cin>>m>>n;
		for(int i=0;i!=m;i++)
			for(int j=0;j!=n;j++)
				cin>>a[i][j];

		if(m==1)
		{
			for(int k=0;k!=n;k++)
				sum+=a[0][k];
		}
		else if(n==1)
		{
			for(int k=0;k!=m;k++)
				sum+=a[k][0];
		}
		else
		{
			for(int k=0;k!=n-1;k++)
				sum+=a[0][k];
			for(int k=0;k!=m-1;k++)
				sum+=a[k][n-1];
			for(int k=n-1;k!=0;k--)
				sum+=a[m-1][k];
			for(int k=m-1;k!=0;k--)
				sum+=a[k][0];
		}

		cout<<sum<<endl;
	}
	return 0;
}


int main()
{
	int k;
	cin >> k;
	int i, j, l, lin, col, sum = 0;
	int num[101][101];
	for(l = 1; l <= k; l++)
	{
		cin >> lin >> col;
		for(i = 1; i <= lin; i++)
		{
			for(j = 1; j <= col; j++)
				cin >> num[i][j];
		}

		if(lin >= 2 && col >= 2)
		{
			for(i = 2; i <= lin - 1; i++)
				sum = sum + num[i][1] + num[i][col];
			for(j = 1; j <= col; j++)
				sum = sum + num[1][j] + num[lin][j];
		}
		if(lin == 1 && col >= 2)
		{
			for(j = 1; j <= col; j++)
				sum = sum + num[1][j];
		}
		if(col == 1 && lin >= 2)
		{
			for(i = 1; i <= lin; i++)
				sum = sum + num[i][1];
		}
		if(col == 1 && lin == 1)
			sum = sum + num[1][1];
		cout << sum << endl;
		sum = 0;
	}
	return 0;
}


/*
 * t3_3.cpp
 *
 *  Created on: 2011-1-8
 *      Author: Lenovo
 */
int main()
{
	int juzhen[101][101];
	int m,n,i,j,sum;
	int k;
	cin>>k;
	while(k>0)
	{sum=0;
	cin>>m>>n;
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			cin>>juzhen[i][j];
			if(i==0)sum+=juzhen[i][j];
			if(i==m-1)sum+=juzhen[i][j];
			if(j==0&&i!=0&&i!=m-1)sum+=juzhen[i][j];
			if(j==n-1&&i!=0&&i!=m-1)sum+=juzhen[i][j];
		}
	}
	cout<<sum<<endl;
	k--;
}
	return 0;
}


int main()
{
	int i, number;
	cin>>number;//???
	for(i=0;i<number;i++)
	{
		int m,n;
		cin>>m>>n;//hang lie
		int a[100][100];//????
		int *p=NULL,*q=NULL,i;
	      for(p=*a;p<*a+n*m;p++)//input
		{
			cin>>*p;
		}
		int sum=0;
		for(p=*a;p<*a+n;p++)//add hang
		{
			sum=sum+*p;
		}
		if(m!=1)//??????
		{
		for(p=*a+(m-1)*n;p<*a+m*n;p++)//add hang
		{
			sum=sum+*p;
		}
		}
		for(p=*a+n;p<*a+(m-1)*n;p=p+n)//add lie
		{
			sum=sum+*p+*(p+n-1);
		}
		cout<<sum<<endl;//output
	}

	return 0;
}


int main()
{
 int n,i,j;
 cin>>n;
 for(i=1;i<=n;i++)
 {
  int row,line,a,b,A[101][101];
  int sum=0;
  cin>>row>>line;
  for(a=1;a<=row;a++)
   for(b=1;b<=line;b++)
     cin>>A[a][b];
   for(a=1;a<=row;a++)
	   sum+=A[a][1];
   for(b=2;b<=line;b++)
	   sum+=A[row][b];
   for(a=row-1;a>=1;a--)
	   sum+=A[a][line];
   for(b=line-1;b>=2;b--)
	   sum+=A[1][b];
   cout<<sum<<endl;
 }

}


int main(int argc, char* argv[])
{
	int k,m,n,i,col,row,sum[100]={0};
	scanf("%d",&k);
	for(i=0;i<k;i++){
		scanf("%d %d",&m,&n);
		int sz[100][100];

		for(row=0;row<m;row++){
			for(col=0;col<n;col++){
				scanf("%d",&sz[row][col]);
			}
		}
		for(col=0;col<n-1;col++) sum[i]+=sz[0][col];
		for(row=0;row<m-1;row++) sum[i]+=sz[row][n-1];
		for(col=n-1;col>0;col--) sum[i]+=sz[m-1][col];
		for(row=m-1;row>0;row--) sum[i]+=sz[row][0];
		printf("%d\n",sum[i]);
	}

	return 0;
}


const int maxn = 110;
int n, m;
int d[maxn][maxn];

int main()
{
    int t;

    scanf("%d", &t);
    while(t-->0)
    {
        int sum = 0;
        scanf("%d%d", &n, &m);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++)
            {
                int tmp;
                scanf("%d", &tmp);
                if(i == 0 || i == n-1 || j == 0 || j == m - 1)
                    sum += tmp;
            }

        printf("%d\n", sum);
    }
 return 0;
}


int main()
{
	int k;
	cin>>k;
	for(int x=1;x<=k;x++)
	{
		int m,n;
		int A[100][100];
		int sum=0,a;
		cin>>m>>n;
		for(int j=1;j<=n;j++)
		{
			cin>>a;
			sum+=a;
		}
		for(int i=2;i<=m-1;i++)
		{
			cin>>a;
			sum+=a;
			for(int j=2;j<=n-1;j++)
				cin>>a;
			cin>>a;
			sum+=a;
		}
		if(n!=1)
		{
			for(int j=1;j<=n;j++)
			{
				cin>>a;
			    sum+=a;
		    }
		}
		cout<<sum<<endl;
	}
	return 0;
}


int mat[MAX][MAX];
int main()
{
//	ifstream cin("a.txt");
	int k;
	cin>>k;
	while(k--)
	{
		int m,n,sum=0;
		cin>>m>>n;
		for(int i=0;i<m;i++)
			for(int j=0;j<n;j++)
				cin>>mat[i][j];
		for(int j=0;j<n;j++)
		{
			if(m>1)
				sum+=mat[m-1][j];
			sum+=mat[0][j];
		}
		for(int i=1;i<m-1;i++)
		{
			if(n>1)
				sum+=mat[i][n-1];
			sum+=mat[i][0];

		}
		cout<<sum<<endl;
	}
	return 0;
}


int main()
{
	int k,sum=0;
	int shuzu[NUM][NUM];
	scanf("%d",&k);
	for(int i=0;i<k;i++)
	{
		int m,n;
		scanf("%d %d",&m,&n);
		for(int s=0;s<m;s++)
		{
			for(int t=0;t<n;t++)
			{
				scanf("%d",&(shuzu[s][t]));
			}
		}
		if(m>2&&n>2)
		{
			for(int x=0;x<m;x++)
			{
				sum+=shuzu[x][0]+shuzu[x][n-1];
			}
			for(int y=1;y<n-1;y++)
			{
				sum+=shuzu[0][y]+shuzu[m-1][y];
			}
		}
		else
		{
			for(int z=0;z<m;z++)
			{
				for(int h=0;h<n;h++)
				{
					sum+=shuzu[z][h];
				}
			}
		}
		printf("%d\n",sum);
		sum=0;
	}
	return 0;
}


int main()
{
	const int max=100;
	int num;
	cin>>num;
	while(num--){
		int m,n;
		cin>>m>>n;
		int a[max][max];
		int i,j;
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				cin>>a[i][j];
			}
		}
		int sum=0;
		for(j=0;j<n;j++){
			if(m==1){
				sum+=a[0][j];
			}
			else{
				sum+=a[0][j];
				sum+=a[m-1][j];
			}
		}
		for(i=1;i<m-1;i++){
			if(n==1){
				sum+=a[i][0];
			}
			else{
				sum+=a[i][0];
				sum+=a[i][n-1];
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}


void main()
{
	int bianyuan();
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		printf("%d\n",bianyuan());

}

int bianyuan()
{
	int c[10000];
	int m,n,i,j,t,sum=0;
	scanf("%d%d",&m,&n);
	t=m*n;
	int *p=c;
	for(i=0;i<t;i++)
		scanf("%d",p+i);//*
	if(t==1)
		return *p;
	for(i=0;i<n-1;i++)
		sum+=*(p+i);
	for(i=1;i<m;i++)
		sum+=*(p+i*n)+*(p+i*n-1);
	for(i=1;i<n;i++)
		sum+=*(p+(m-1)*n+i);
	return sum;
}


int main()
{
	int k,row,q,col,i,j,*a,*num;
	scanf("%d",&k);
    num=(int*)malloc(k*sizeof(int));
	for(q=0;q<k;q++)
	{
		int sum=0;
		scanf("%d %d",&row,&col);
		a=(int*)malloc(row*col*sizeof(int));
		for(i=0;i<row;i++)
			for(j=0;j<col;j++)
			{
				scanf("%d",a+i*col+j);
				if(i==0||j==0||i==row-1||j==col-1)sum=sum+*(a+i*col+j);
			}
        *(num+q)=sum;
		free(a);
	}
    for(q=0;q<k;q++)
		printf("%d\n",*(num+q));
	free(num);
}


int main()
{
	int k;
	cin>>k;
	while(k--)
	{

		int array[100][100];
		int m,n;
		cin>>m>>n;
		for(int i=0;i!=m;i++)
			for(int j=0;j!=n;j++)
				cin>>array[i][j];
		int sum=0;
		if(m==1&&n==1)
			sum=array[0][0];
		else
		{
			for(int k=0;k!=n-1;k++)
				sum+=array[0][k];
			for(int k=0;k!=m-1;k++)
				sum+=array[k][n-1];
			for(int k=n-1;k!=0;k--)
				sum+=array[m-1][k];
			for(int k=m-1;k!=0;k--)
				sum+=array[k][0];
		}
		cout<<sum<<endl;

	}
	return 0;
}


int main()
{
    int i,k,row,col,ROW,sz[100][100],COL,sum[100];
    scanf("%d", &k);
    for(i=0;i<k;i++)
    {
                    sum[i]=0;
                    }
    for(i=0;i<k;i++)
    {
                     scanf("%d %d", &ROW, &COL);
                     for(row=0;row<ROW;row++)
                     {
                                              for(col=0;col<COL;col++)
                                              {
                                                                      scanf("%d", &sz[row][col]);
                                              }
                                              }
                    if(ROW==1&&COL==1)
                    {
                                      sum[i]=sum[i]+sz[0][0];
                                      }
                     else
                     {
                     for(col=0;col<COL;col++)
                     {
                                             sum[i]=sum[i]+sz[0][col]+sz[ROW-1][col];
                     }
                     for(row=1;row<(ROW-1);row++)
                     {
                                                 sum[i]=sum[i]+sz[row][0]+sz[row][COL-1];
                     }
                     }

    }
    for(i=0;i<k;i++)
    {
    printf("%d\n", sum[i]);
    }
scanf("%d", &k);
return 0;
}


int main(int argc, char* argv[])
{
	int n;
	int p;
	int q;
	int i , j , k;
	scanf("%d" , &n);
	for(i = 0 ; i < n ; i++)
	{
		int sum = 0;
		int num;
		scanf("%d" , &p);
		scanf("%d" , &q);
		if(p == 1 && q == 1)
		{
			scanf("%d" , &num);
			printf("%d" , num);
			break;
		}
		for(j = 0 ; j < q ; j++)
		{
			scanf("%d" , &num);
			sum += num;
		}
		for(j = 1 ; j < p-1 ; j++)
		{
			for(k = 0 ; k < q ; k++)
			{
				scanf("%d" , &num);
				if(k == 0 || k == q-1)
				{
					sum += num;
				}
			}
		}
		for(j = 0 ; j < q ; j++)
		{
			scanf("%d" , &num);
			sum += num;
		}
		printf("%d\n" , sum);
	}

	return 0;
}


int init(){
	//?????
	int k,t,m,n,ans;
	cin>>k;
	while(k){
		k--;
		ans=0;
		cin>>m>>n;
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				cin>>t;
				if(i==0||i==m-1||j==0||j==n-1)ans+=t;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

int main(){
	init();
	return 0;
}


int bianyuan(int n,int m){
	int juzhen[100][100];
	int i,j,result;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&juzhen[i][j]);
		}
	}
	result=0;
	for(j=0;j<m;j++){
		result+=juzhen[0][j];
	}
	for(j=0;j<m;j++){
		result+=juzhen[n-1][j];
	}
	for(i=1;i<n-1;i++){
		result+=juzhen[i][0];
	}
	for(i=1;i<n-1;i++){
		result+=juzhen[i][m-1];
	}
	return result;
}
int main()
{
	int n,i;
	int a,lie,hang;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&lie,&hang);
		a=bianyuan(lie,hang);
		printf("%d\n",a);
	}
	return 0;
}


int main(int argc, char* argv[])
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		int row;
		int col;
		int total=0;
		int s[100][100];
		scanf("%d%d",&row,&col);
		int x,y;
		for(x=0;x<row;x++){
			for(y=0;y<col;y++){
				scanf("%d",&s[x][y]);
			}
		}
		if(row<3||col<3){
			for(x=0;x<row;x++){
			   for(y=0;y<col;y++){
				total+=s[x][y];
			}
			}
			printf("%d\n",total);
			}else{
		for(y=0;y<col;y++){
			total+=s[0][y];
		}
		for(y=0;y<col;y++){
			total+=s[row-1][y];
		}
		for(x=0;x<row;x++){
			total+=s[x][0];
		}
		for(x=0;x<row;x++){
			total+=s[x][col-1];
		}
		total=total-s[0][0]-s[0][col-1]-s[row-1][0]-s[row-1][col-1];
		printf("%d\n",total);
			}

	}
	return 0;
}


void main(){
	int k,m,n,p;
	int matrix(int m,int n);
	scanf("%d",&p);
	for(k=0;k<p;k++){
		scanf("%d%d",&m,&n);
		printf("%d\n",matrix(m,n));
	}
}

int matrix(int m,int n){
	int i,j,a,sum=0;
	for(i=0;i<m;i++) for(j=0;j<n;j++) {
		scanf("%d",&a);
		if(i==0||i==m-1||j==0||j==n-1) sum+=a;
	}
	return sum;
}


int k,m,n;
int arr[105][105];

int main()
{
    cin>>k;
    while(k--)
    {
        cin>>m>>n;
        int sum=0;
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                cin>>arr[i][j];
                if(i==0||i==m-1||j==0||j==n-1)
                    sum+=arr[i][j];
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}


int main()
{
	int t,m,n,array[100][100];
	int sum,i,j,k;
	cin>>t;
	for(i=0;i<t;i++)
	{
		sum=0;
		cin>>m>>n;
		for(j=0;j<m;j++)
			for(k=0;k<n;k++)
				cin>>array[j][k];
		for(j=0;j<m;j++)
			sum=sum+array[j][0]+array[j][n-1];
		for(k=0;k<n;k++)
			sum=sum+array[0][k]+array[m-1][k];
		cout<<sum-array[0][0]-array[0][n-1]-array[m-1][0]-array[m-1][n-1]<<endl;
	}
	cin.get();
	return 0;
}


int main()
{
	int k,m,n,num[100][100],count1,count2,count3,sum;
	int *pointer=NULL;
	cin>>k;
	while (k--)
	{
		sum=0;
		cin>>m>>n;
		for ( count1=0;count1<m;count1++ )
		{
			for (count2=0;count2<n;count2++)
			{cin>>num[count1][count2];}                      //????
		}
		for ( pointer=num[0];pointer<num[0]+n;pointer++ )    //?????????
		{
			sum=sum+*pointer;
		}
		for (pointer=num[m-1];pointer<num[m-1]+n;pointer++)  //????????
		{
			sum=sum+*pointer;
		}
		for (pointer=num[1]+n-1,count3=1;count3<m-1;pointer=num[++count3]+n-1)   //????
		{
			sum=sum+*pointer;
		}
		for (pointer=num[1],count3=1;count3<m-1;pointer=num[++count3])    //????
		{
			sum=sum+*pointer;
		}
		cout<<sum<<endl;
	}
	return 0;
}


int main()
{
	int square[100][100];
	int k, i, j;
	int (* p)[100];
	p = square;
	int sum = 0;
	for (cin >> k; k; --k)
	{
		int wide;
		int height;
		sum = 0;
		cin >> height >> wide;
		for (i = 0; i < height; i++)
			for (j = 0; j < wide; j++)
				cin >> square[i][j];
		p = square;
		for (i = 0; i < height; i++)
			for (j = 0; j < wide; j++)
			{
				if (i == 0 || j == 0 || i == height - 1 || j == wide - 1)
					sum += * ( * (p + i) + j);
			}
			cout << sum << endl;
	}
	return 0;
}


int main()
{
  char origin[256], sub[256], replace[256], after[256];
  scanf("%s%s%s", origin, sub, replace);

  int i, j, k=0;

  for (i=0; origin[i]; i++) {
    int shouldChange=1;
    for (j=0; sub[j]; j++) {
      if (origin[i+j]!=sub[j]) {
        shouldChange=0;
      }
    }
    if (shouldChange==1) {
      strcpy(after, origin);
      after[i]=0;
      strcat(after, replace);
      strcat(after, &origin[i+strlen(sub)]);
      strcpy(origin, after);
      i+=strlen(replace);
      break;
    }
  }
  printf("%s", origin);
  return 0;
}


int main(){
char zf[100];
char zq[100];
char cu[100];
char dt[100][100];
int i,l,lc,j,lz,k=0,t,m,n=0,len,ci;
gets(zf);
gets(cu);
gets(zq);
l=strlen(zf);
lc=strlen(cu);
lz=strlen(zq);
for(i=0;i<l;i++){
    if(zf[i]==cu[0]){
         ci=1;
		for(j=0;j<lc;j++,i++){
			if(zf[i]!=cu[j]){
			   ci=0;
			   break;
			}

		}
		if(ci==1){
			t=i-lc;
		   for(j=0;j<lc;j++,t++){
			   zf[t]=zq[j];

		   }
		   break;

		}
	}
}

          printf("%s",zf);

return 0;
}


main()
{
      char a[260];
      char b[260];
      char c[260];
      scanf ("%s",a);
      scanf ("%s",b);
      scanf ("%s",c);
      int len1=strlen(a);
      int len2=strlen(b);
      int len3=strlen(c);
      int i,j,length;
      for (i=0;i<len1;i++)
      {
          length=0;
          for (j=0;j<len2;j++)
          {
              if (a[i+j]==b[j]) length=length+1;
          }
          if (length==len2)
          {
              for (j=0;j<i;j++)
              {
                  printf ("%c",a[j]);
              }
              for (j=0;j<len3;j++)
              {
                  printf ("%c",c[j]);
              }
              for (j=i+len3;j<len1;j++)
              {
                  printf ("%c",a[j]);
              }
              printf ("\n");
              break;
          }
      }
      if (length!=len2) printf ("%s\n",a);
}


void main()
{
	char a[300],b[300],c[300];
	int i,j,n=0,lena,lenb;
	scanf("%s%s%s",a,b,c);
	lena=strlen(a);
	lenb=strlen(b);
	for (i=0;i<lena;i++)
	{
		if (b[0]==a[i])
		{
			for (j=0;j<lenb;j++)
			{
				if (b[j]==a[i+j])
				{
					n++;
				}
			}
		}
		if (n==lenb) break;
		else n=0;
	}
    if (i<lena)
	{
		for (j=0;j<lenb;j++)
		{
			a[i+j]=c[j];
		}
	}
	printf("%s",a);
}


// ?????5.cpp : ??????????????
//

int strnl(char *,char *);
void replace(char *str,int len_ss,int start,char *rpl);

int main()
{
	char str[256],substr[256],rpl[256];
	int start;
	scanf("%s %s %s",str,substr,rpl);
	start=strnl(str,substr);
	if(start!=-1)
		replace(str,strlen(substr),start,rpl);
          else
               printf("%s\n",str);
	return 0;
}

int isstart(int i,char *s,char *subs)
{
	char temp[256];
	char *p,*pt;
	p=s+i;
	pt=temp;
	int j;
	for(j=0;j<strlen(subs);j++)
		*pt++=*p++;
	*pt=0;
	if(!strcmp(temp,subs))
		return 1;
	return 0;
}

int strnl(char *s,char *subs)
{
	int i;
	for(i=0;i<=strlen(s)-strlen(subs);i++)
		if(isstart(i,s,subs))
			return i;
	return -1;
}

void replace(char *str,int len_ss,int start,char *rpl)
{
	char temp[256];
	strcpy(temp,str);
	char *ptmp,*prpl;
	ptmp=temp+start;
	prpl=rpl;
	while(*prpl)
		*ptmp++=*prpl++;
	char *pstr=str+start+len_ss;
	while(*pstr)
		*ptmp++=*pstr++;
	*ptmp=0;
         strcpy(str,temp);
	printf("%s\n",temp);
}


int main()
{
    int m,n,i,j,p,f;
    char str[257],a[257],b[257];
    gets(str);
    gets(a);
    gets(b);
    n=strlen(str);
    m=strlen(a);
    p=1;

    for(i=0;i<n;i++)
    {
        f=1;
        for(j=0;j<m;j++)
            if(str[i+j]!=a[j])
            {
                f=0;
                break;
            }
        if((p)&&(f))
        {
           printf("%s",b);
           p=0;
           i+=m-1;
        }
        else
            printf("%c",str[i]);
    }

    return 0;
}


int strnl(char *,char *);
void replace(char *str,int len_ss,int start,char *rpl);

int main()
{
	char str[256],substr[256],rpl[256];
	int start;
	scanf("%s %s %s",str,substr,rpl);
	start=strstr(str,substr);
	if(start)
		replace(str,strlen(substr),(char *)start-str,rpl);
          else
               printf("%s\n",str);
	return 0;
}

int isstart(int i,char *s,char *subs)
{
	char temp[256];
	char *p,*pt;
	p=s+i;
	pt=temp;
	int j;
	for(j=0;j<strlen(subs);j++)
		*pt++=*p++;
	*pt=0;
	if(!strcmp(temp,subs))
		return 1;
	return 0;
}

int strnl(char *s,char *subs)
{
	int i;
	for(i=0;i<=strlen(s)-strlen(subs);i++)
		if(isstart(i,s,subs))
			return i;
	return -1;
}

void replace(char *str,int len_ss,int start,char *rpl)
{
	char temp[256];
	strcpy(temp,str);
	char *ptmp,*prpl;
	ptmp=temp+start;
	prpl=rpl;
	while(*prpl)
		*ptmp++=*prpl++;
	char *pstr=str+start+len_ss;
	while(*pstr)
		*ptmp++=*pstr++;
	*ptmp=0;
         strcpy(str,temp);
	printf("%s\n",temp);
}


int main()
{
	char s[256],sub[256],re[256];
	gets(s);
	gets(sub);
	gets(re);
	int i,length,lensub,j,k,ans=0;
	length=strlen(s);
	lensub=strlen(sub);
	for(i=0;i<length;i++)
		if(s[i]==sub[0])
		{
			for(j=0;j<lensub;j++)
				if(s[i+j]!=sub[j]) break;
			if(j==lensub)
			{
				ans=1;
				for(k=0;k<i;k++)
		            printf("%c",s[k]);
	            printf("%s",re);
	            for(k=i+lensub;k<length;k++)
		            printf("%c",s[k]);
				break;
			}
		}
	if(ans!=1) printf("%s",s);
	return 0;
}


int main(){
   char zfc[LEN],x[LEN],y[LEN],w[LEN];
   int len1,len2,len3,i,j,flag=0,m,tag,k=0;
   gets(zfc);
   gets(x);
   gets(y);
   len1=strlen(zfc);
   len2=strlen(x);
   len3=strlen(y);
   for(i=0;i<len1;i++){
          if(zfc[i]==x[0]){
           m=i;
           tag=0;
             for(j=0;j<len2;j++){
                 if(zfc[i+j]!=x[j]){
                   tag=1;
                   break;
                   }
                   }
             if(tag==0){
                        strcpy(w,zfc);
                        for(j=0;j<len3;j++){
                            zfc[m+j]=y[j];
                            }
                         if(m+len3>len1||m+len3==len1){
                                                       zfc[m+len3]='\0';
                                                       }
                         else if(m+len3<len1){
                                         for(i=m+len3;i<len1+len3-len2;i++){
                                             zfc[i]=w[m+len2+k];
                                             k++;
                                             }
                                         zfc[len1+len3-len2]='\0';
                                         }
                        flag=1;
                            }

                   }
                   }

      printf("%s\n",zfc);
                     return 0;
}


int main()
{
	char a[256],b[256],c[256];
	cin>>a>>b>>c;
	int L,l,x,y;
	L=strlen(a);
	l = strlen(b);
	for(x=0;x<=L-l;x++)
	{
		if(a[x]!=b[0])
			continue;
		else
		{
			for(y=0;y<l;y++)
				if(a[x+y]!=b[y])
					break;
			if(y!=l)
				continue;
			else
				break;
		}
	}
	if(x==L-l+1)
		cout<<a<<endl;
	else
	{
		int i=0;
		while(i!=x)
		{
			cout<<a[i];
			i++;
		}
		cout<<c;
		cout<<a+i+l<<endl;
	}
	return 0;
}


int main()
{
	char a[256],b[256],c[256];
	gets(a);
	gets(b);
	gets(c);
	char *t;
	t=strstr(a,b);
	if(t==NULL)
	{
		printf("%s",a);
		return 0;
	}
	else
	{
		char f=t-a;
		int d=strlen(a),e=strlen(c);
		int i=f,j;
		for(j=0;j<e;j++)
		{
			a[i]=c[j];
			i++;
			if(i==t-a+e)
				break;
		}
	}
	printf("%s",a);
}


int main()
{
	char string[500],substring[500],replacement[500],temp,str[500];
	int i,j,k,l,m,len0,len1,len2;
	gets(string);

	gets(substring);

	gets(replacement);

	len1=strlen(substring);

	len2=strlen(replacement);

	len0=strlen(string);

	strcpy(str,string);

	for(i=0;i<len0;i++)
	{
		if(string[i]==substring[0])
		{
		  for(j=1;j<len1;j++)
		  {
			if(	string[i+1]==substring[j])
				i++;
			else
			{	j=0;
				break;
			}
		  }

		  if(j==len1)
		  {
			k=i;
			for(i;i<len0-len1+len2;i++)
			{
				str[i-len1+len2]=string[i];
			}
			for(l=0;l<len2;l++)
			{
				str[k-len2+1+l]=replacement[l];
			}
		  }
		else
			m=0;
		}
	}

	puts(str);
     return 0;
}


int main()
{
	char s[257], sub[50], rep[50];
	int i, j, t, k;
	int len_s, len_sub;
	cin.getline(s, 257);
	cin.getline(sub, 50);
	cin.getline(rep, 50);
	len_s = strlen(s);
	len_sub = strlen(sub);
	for (t = 0; t < len_s; t++)
	{
		if (s[t] == sub[0])
		{
			for (i = 0; i < len_sub; i++)
			{
				if (s[t + i] != sub[i])
					break;
			}
			if (i == len_sub)
				break;
		}
	}
	if (t == len_s)
		cout << s << endl;
	else
	{
		for (i = 0; i < t; i++)
			cout << s[i];
		cout << rep;
		for (k = 0; s[i + len_sub + k] != '\0'; k++)
			cout << s[i + len_sub + k];
		cout << endl;
	}
	return 0;
}


void main()
{
    char f(char str[],char substr[],char rep[]);
	char str[256],substr[256],rep[256];
	scanf("%s %s %s",str,substr,rep);
    f(str,substr,rep);
	puts(str);
}
char f(char str[256],char substr[256],char rep[256])
{
	char s[256];
	int i=0,j,k;
	for(i=0;str[i]!='\0';i++)
	{
		if(str[i]==substr[0])
		{
		   	for(j=0;j<strlen(substr);j++)
				s[j]=str[j+i];
			s[j]='\0';
			if(strcmp(substr,s)==0)
			{
				for(k=0;k<strlen(rep);k++,i++)
					str[i]=rep[k];
				return 0;
			}
		}
	}
	return 0;
}


int main(){
    char su[100],zu[100],tu[100];
    gets(su);
    gets(zu);
    gets(tu);
    int i,j,k,t;
    for(i=0;i<strlen(su);i++){
		for(k=0,j=i;su[j]==zu[k];j++,k++)
    if(k==strlen(zu))
    break;
    if(k==strlen(zu))
    break;
    }
    //printf("%d%d",i,j);
	if(j!=i-1){
    for(t=0;t<i;t++)
    printf("%c",su[t]);
    printf("%s",tu);
    for(t=j;t<strlen(su);t++)
		printf("%c",su[t]);}
	else
		printf("%s",su);
    return 0;
    }


void main()
{
	char a[256],b[256],c[256];
	gets(a);
	gets(b);
	gets(c);
	int q,w,e;
	q=strlen(a);
	w=strlen(b);
	e=strlen(c);
	int i,j,k;
	int result=1,d;
	for(k=0;k<q;k++)
	{
		if(a[k]==b[0])
		{
			result=1;
			for(i=k,j=0;i<w+k,j<w;i++,j++)
			{
				d=a[i]-b[j];
				if(d!=0)  result=0;
			}
			if(result)
			{
				for(i=k,j=0;j<e,i<w+k;i++,j++)
				{
					a[i]=c[j];
				}
				break;
			}
		}
	}
	puts(a);
}


//
//  main.cpp
//  ????
//
//  Created by ? ?? on 12-12-27.
//  Copyright (c) 2012? ? ??. All rights reserved.
//

int main()
{
    int i = 0;
    char string[300];
    char substring[300];
    char replace[300];
    cin >> string;
    cin >> substring;
    cin >> replace;
    int l = strlen(string);
    int l1 = strlen(substring);
    int l2 = strlen(replace);
    char *p = strstr(string, substring);
    if (p != NULL)
    {
        while(i < l2)
        {
            *p = replace[i];
            i++;
            p++;
        }
    }
    cout << string;
    return 0;
}


int main()
{
	char zfc1[257]={0},zfc2[257]={0},zfc3[257]={0},zichuan[257]={0};
	int len1,len2,i,j,k,t,flag=0;
	int temp;
	scanf("%s",zfc1);
	scanf("%s",zfc2);
	scanf("%s",zfc3);
	len1=strlen(zfc1);
	len2=strlen(zfc2);
	for(i=0;i<=len1-len2;i++)
	{
		for(j=0;j<len2;j++)
		{
			zichuan[j]=zfc1[j+i];
		}
		if(strcmp(zichuan,zfc2)==0)
		{
			flag=1;
			temp=i;
			break;
		}
	}
	if(flag==0)
	{
		printf("%s",zfc1);
	}
	else
	{
			for(k=0;k<temp;k++)
			{
				printf("%c",zfc1[k]);
			}
			printf("%s",zfc3);
			for(t=temp+len2;zfc1[t]!='\0';t++)
			{
				printf("%c",zfc1[t]);
			}
	}
	return 0;
}


int main(){
    char zfc[256],wt[256],tar[256];
	int i,j,tag;
	scanf("%s",zfc);
	scanf("%s",wt);
	scanf("%s",tar);
	int n=strlen(zfc);
	int k=strlen(wt);
	for(i=0;i<n-k+1;i++){
		tag=0;
		for(j=i;j<i+k;j++){
			if(zfc[j]!=wt[j-i]){
				tag=1;
				break;
			}
		}
		if(tag==0){
			for(j=i;j<i+k;j++){
				zfc[j]=tar[j-i];
			}
			break;
		}
	}
	puts(zfc);

	return 0;
}


char a[2000];
char sub[2000];
int b[2000];
int main()
{
	gets(a);
	gets(sub);
	int i=0,j=0,l=strlen(a),l_sub=strlen(sub);
	while(i<l)
	{
		for(j=0;j<l_sub;j++)
		{
			if(a[i+j]==sub[j])
			{
				b[i]++;
			}
		}
		i++;
	}
	int k=0,count=0,w=999;
	for(k=0;k<2000;k++)
	{
		if(b[k]==l_sub)
		{
			w=k;
			count++;
			break;
		}
	}
	char c[300];
	gets(c);
	int q=0;
	if(count!=0)
	{
	while(q<l)
	{
		if(q==w)
		{
			printf("%s",c);
			q+=l_sub;
		}
		if(q!=l)
		{printf("%c",a[q]);}
		q++;
	}
	}
	else if(count==0)
	{
		puts(a);
	}
	return 0;
}


main()
{
   char str[257];
   char sub[257];
   char rep[257];
   int i=0,j=0,k=0,a;
   gets(str);
   gets(sub);
   gets(rep);
   a=strlen(sub);
   for(i=0;str[i]!='\0';i++)
   {
        if(str[i]==sub[j])
        {
          j++;
          if(j==a)
          {
            k=i;
            break;
          }
        }
        else j=0;
   }
   for(i=0;str[i]!='\0';i++)
   {
      if(i==k-a+1)
      {
        printf("%s",rep);
        i=k;
      }
      else printf("%c",str[i]);
   }
   getchar();
   getchar();
   getchar();
}


int main()
{
	char zfc1[257]={0},zfc2[257]={0},zfc3[257]={0},zichuan[257]={0};
	int len1,len2,i,j,k,t,flag=0;
	scanf("%s",zfc1);
	scanf("%s",zfc2);
	scanf("%s",zfc3);
	len1=strlen(zfc1);
	len2=strlen(zfc2);
	for(i=0;i<=len1-len2;i++)
	{
		for(j=0;j<len2;j++)
		{
			zichuan[j]=zfc1[j+i];
		}
		if(strcmp(zichuan,zfc2)==0)
		{
			for(k=0;k<i;k++)
			{
				printf("%c",zfc1[k]);
			}
			printf("%s",zfc3);
			for(t=i+len2;zfc1[t]!='\0';t++)
			{
				printf("%c",zfc1[t]);
			}
			flag=1;
			break;
		}
	}
	if(flag==0)
	{
		printf("%s",zfc1);
	}
	return 0;
}