//       In the name of         ****                      God                     ****

/*

Copyright (C)          oofMan

                                   Morocco

created : 30/3/2019

*/
#include <stdio.h>
#include <stdbool.h>
//#include <bits/stdc++.h>

//using namespace std;

/*inline void oofMan() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}*/

char m[4][4];
int main(void) {
    //oofMan();
    bool flag=false;
    int xc[3]={1,0,1};
    int yc[3]={0,1,1};
    for(int i=0 ;i<4 ;i++)
        for(int j=0 ; j<4 ;j++)
            scanf(" %c",&m[i][j]);

    for(int i=0 ;i<3 ;i++)
        for(int j=0 ; j<3 ;j++){
            int counter=0;
            for(int k=0;k<3;k++){
                if(i+xc[k]<4 && j+yc[k]<4)
                    if(m[i][j]!=m[i+xc[k]][j+yc[k]])
                        counter++;
            }
            if(counter==3 || counter<=1){
                flag=true;
                break;
            }

        }

    printf("%s",(flag?"YES":"NO"));

}

/* بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ */
/* رَّبِّ زِدْنِى عِلْمًا */

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

#define OUTPUT freopen("myfile.txt","w",stdout);
#define INPUT freopen("input.txt","r",stdin);

int main()
{
    int i,j,cnt,test;
    char mat[20][20];

    while(gets(mat[0]))
    {
        gets(mat[1]);
        gets(mat[2]);
        gets(mat[3]);

        cnt=0;
        test=0;

        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                cnt=0;

                if(mat[i][j]=='#')
                    cnt++;
                if(mat[i][j+1]=='#')
                    cnt++;
                if(mat[i+1][j]=='#')
                    cnt++;
                if(mat[i+1][j+1]=='#')
                    cnt++;

                if(cnt>=3)
                    {
                        test=1;
                        goto ans;

                    }

                cnt=0;

                if(mat[i][j]=='.')
                    cnt++;
                if(mat[i][j+1]=='.')
                    cnt++;
                if(mat[i+1][j]=='.')
                    cnt++;
                if(mat[i+1][j+1]=='.')
                    cnt++;

                if(cnt>=3)
                    {
                        test=1;
                        goto ans;

                    }
            }
        }

        ans:
            if(test==1)
                printf("YES\n");
            else
                printf("NO\n");

    }

    return 0;

}

#include<stdio.h>
int main(){
    char squareArray[4][4];
    int i,flagHash=0,flagDot=0,j,countHash,countDot;
    for(i=0;i<4;i++){
        scanf("%s",squareArray[i]);
    }
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            countHash = 0;
            countDot = 0;
            if(squareArray[i][j]=='#')countHash++;
            else if(squareArray[i][j]=='.')countDot++;

            if(squareArray[i][j+1]=='#')countHash++;
            else if(squareArray[i][j+1]=='.')countDot++;

            if(squareArray[i+1][j]=='#')countHash++;
            else if(squareArray[i+1][j]=='.')countDot++;

            if(squareArray[i+1][j+1]=='#')countHash++;
            else if(squareArray[i+1][j+1]=='.')countDot++;

            if(countHash>=3){
                flagHash=1;
                break;
            }
            else if(countDot>=3){
                flagDot=1;
                break;
            }
        }
        if(flagHash^flagDot)break;
    }
    if(flagHash^flagDot)printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include <stdio.h>

int main(void) {
	char square[4][4];
	char garb;
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 4; j++) {
			scanf("%c", &square[i][j]);
			//printf("I scanned %c", square[i][j]);
		}
		scanf("%c", &garb);
	}
	int tru = 0;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			int dots = 0;
			if (square[i][j] == '.') {
				dots++;
			}
			if (square[i][j+1] == '.') {
				dots++;
			}
			if (square[i+1][j] == '.') {
				dots++;
			}
			if (square[i+1][j+1] == '.') {
				dots++;
			}
			if (dots != 2) {
				tru = 1;
				//printf("square at (%d, %d). dots == %d\n", i, j, dots);
				//printf("(%d, %d) = %c, (%d, %d) = %c, (%d, %d) = %c, (%d, %d) = %c.\n", i, j, square[i][j], i, j + 1, square[i][j+1], i + 1, j, square[i+1][j], i + 1, j + 1, square[i+1][j+1]);
			}
		}
	}
	if (tru == 1) {
		printf("YES");
	} else {
		printf("NO");
	}
	return 0;
}

#include <stdio.h>
#define mian main
int mian (void) {
    int a[4][4], s, flag = 0;
    char c;
    for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j) {
            c = getchar();
            while (c != '#' && c != '.') c = getchar();
            if (c == '#') a[i][j] = 1;
            else a[i][j] = 0;
        }
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) {
            s = a[i][j] + a[i][j+1] + a[i+1][j] + a[i+1][j+1];
            if (s != 2) {
                printf("YES\n");
                flag = 1;
                return 0;
            }
        }
    printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f -*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX 4
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;
int preprocess()
{
   return 0;
}
char board[MAX][MAX+1];

int main()
{
   int cases;
   int i,j,n;
   int a[MAX];
   preprocess();
   for(i=0;i<4;++i)
      ss(board[i]);
   for(i=0;i<3;++i)
      for(j=0;j<3;++j){
         //printf("i j %d %d\n",i,j);
         int cnt=0;
         cnt+=(board[i][j]=='#');
         cnt+=(board[i+1][j]=='#');
         cnt+=(board[i][j+1]=='#');
         cnt+=(board[i+1][j+1]=='#');
         if(cnt!=2){
            printf("YES\n");
            exit(0);
         }
      }
   printf("NO\n");
   return 0;
}

#include<stdio.h>

struct string
{
    char s[4];
};
int main()
{
    int i,j,sum=0,temp=0;
    char a[4][4];
    for(i=0;i<4;i++)
    scanf("%s",a[i]);
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
        {
            temp=1;
            if(a[i][j+1]==a[i][j])
            temp++;
            if(a[i+1][j]==a[i][j])
            temp++;
            if(a[i+1][j+1]==a[i][j])
            temp++;
            sum=sum>temp?sum:temp;
        }
    j==3;
    if(sum>=3);
    else
    for(i=0;i<3;i++)
    {
        temp=1;
        if(a[i][j]==a[i+1][j])
        temp++;
        if(a[i][j]==a[i+1][j-1])
        temp++;
        sum=sum>temp?sum:temp;
    }
    if(sum>=3)
    printf("YES");
    else
    printf("NO");
    return 0;
}

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

int main()
{
    int i,j;
    char ch;
    int f=0;
    char arr[4][4];
    for(i=0;i<4;i++)
        {for(j=0;j<4;j++)
            {scanf("%c",&arr[i][j]);}
        scanf("%c",&ch);}
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            //printf("%c ",arr[i][j]);
            if(arr[i][j]==arr[i][j+1] && arr[i][j]==arr[i+1][j])
            {
                printf("YES ");
                f=1;
                break;
            }
            else if(arr[i][j]==arr[i][j+1] && arr[i][j]==arr[i+1][j+1])
            {
                printf("YES ");
                f=1;
                break;
            }
            else if(arr[i][j]==arr[i+1][j] && arr[i][j]==arr[i+1][j+1])
            {
                printf("YES ");
                f=1;
                break;
            }
            else if(arr[i+1][j]==arr[i+1][j+1] && arr[i+1][j]==arr[i][j+1])
            {
                printf("YES");
                f=1;
                break;
            }
        }
        //printf("\n");
        if(f==1)
        break;
    }
    if(f==0)
    printf("NO");
    return 0;
}

#include<stdio.h>
#include<stdbool.h>

char tab[5][5];
bool contour(int i,int j);

int main()
{
    int k=0;
    int i,j;

    for(i=0;i<4;i++)scanf("%s",tab[i]);

//main
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if (contour(i,j)){printf("YES \n"); k++; break; }

        }
        if(k!=0)break;
    }
    if(k==0)printf("NO \n");

    return 0;
}

bool contour(int i,int j)
{
    if     ((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j])){return 1;}
    else if((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else if((tab[i][j]==tab[i+1][j])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else if((tab[i][j+1]==tab[i+1][j])&&(tab[i][j+1]==tab[i+1][j+1])){return 1;}
    else return 0;
}

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

char s[5][5];
int dnf(int x,int y)
{
    int v=1;
    if(y==3)
        dnf(x+1,0);
    else if(x+1<4&&y+1<4)
    {
        if(s[x][y]==s[x][y+1])
            v++;
        if(s[x][y]==s[x+1][y])
            v++;
        if(s[x][y]==s[x+1][y+1])
            v++;
        if(v>2||v==1)
            return 1;
        else
            dnf(x,y+1);
    }
}
int main()
{
    int i,j;
    for(i=0; i<4; i++)
        scanf("%s",&s[i]);
    if(dnf(0,0)==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

#include<stdio.h>
//#include<conio.h>
int main()
{
 char str[4][4],temp;
 int i,j,found=0,count;
 for(i=0;i<4;i++)
 {
  scanf("%s",str[i]);
 }
 for(i=0;i<3 && found==0;i++)
 {
  for(j=0;j<3 && found==0;j++)
  {
   count=1;
   temp=str[i][j];
   if(str[i][j+1]==temp)
    count++;
   if(str[i+1][j]==temp)
    count++;
   if(str[i+1][j+1]==temp)
    count++;
   if(count==4 || count==3 || count==1)
    found=1;
  }
 }
 if(found==1)
  printf("YES");
 else
  printf("NO");
//  getch();
//  clrscr();
return 0;
}

#include <stdio.h>

int main()
{
	char paper[4][4];
	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 4; ++j)
		{
			paper[i][j] = getchar();
		}
		getchar();
	}

	char count = 0;
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			if (paper[i][j] == paper[i + 1][j])
			{
				++count;
			}
			if (paper[i][j] == paper[i][j + 1])
			{
				++count;
			}
			if (paper[i][j] == paper[i + 1][j + 1])
			{
				++count;
			}
			if (count != 1)
			{
				puts("YES");
				return 0;
			}
			count = 0;
		}
	}
	puts("NO");

	return 0;
}

#include<stdio.h>

char grid[4][4];

int isBlack(int i,int j)
{
    if(grid[i][j] == '#')
        return 1;
    else
        return 0;
}

int find(int i,int j)
{
    if(isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && !isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && isBlack(i,j+1) && !isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;

    if(!isBlack(i,j) && !isBlack(i,j+1) && !isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && !isBlack(i,j+1) && !isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && !isBlack(i,j+1) && isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && isBlack(i,j+1) && !isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && !isBlack(i,j+1) && !isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    return 0;
}

int solve()
{
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(find(i,j)==1)
                return 1;
        }
    }
    return 0;
}

int main()
{
    int i,j;
    char s[5];
    for(i=0;i<4;i++)
    {
        scanf("%s",s);
        for(j=0;j<4;j++)
            grid[i][j] = s[j];
    }

    if(solve()==1)
        printf("YES");
    else
        printf("NO");
    return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,x1,y1,k,sum2,min,f,r,o,sum1,sum=0,y,count1, a[26]={0};
char a1[10][10];
for(i=0;i<4;i++){
    scanf("%s",a1[i]);
}
for(i=0;i<=2;i++){
    for(j=0;j<=2;j++){
        x1=0;

        if(a1[i][j]=='#'){
            x1++;
        }
        if(a1[i][j+1]=='#'){
            x1++;
        }
        if(a1[i+1][j+1]=='#'){
            x1++;
        }
        if(a1[i+1][j]=='#'){
            x1++;
        }
        if(x1==0 || x1==3 || x1==1 || x1==4){
            printf("YES\n");
            return 0;
        }
    }
}

printf("NO");

return 0;
}

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

int main()
{
    int i,arr[4][4],j,count,fl=0;
    char str[5];
    i=0;
    while(i<4)
    {
        memset(str,'\0',5);
        //printf("enter the string:");
        gets(str);
        for(j=0;str[j]!='\0';j++)
        {
            if(str[j]=='#')
                arr[i][j]=1;
            else if(str[j]=='.')
                arr[i][j]=0;
        }
        i++;
    }
/*  for(i=0;i<4;i++)
    {
        for(j=0;j<4;j++)
            printf("%d ",arr[i][j]);
        printf("\n");
    }*/
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            count=0;
            if(arr[i][j]==1)
                count++;
            if(arr[i][j+1]==1)
                count++;
            if(arr[i+1][j]==1)
                count++;
            if(arr[i+1][j+1]==1)
                count++;
            if(count==3 || count==4 || count==1 || count==0)
                fl=1;
        }
    }
    if(fl==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

int main()
{
    int i, j, isWhite = 0, isBlack = 0, stat = 0;
    char s[10];
    char arr[4][4];
    for (i = 0; i < 4; i++){
        scanf("%s", &s);
        for (j = 0; j < 4; j++) arr[i][j] = s[j];
    }
    for (i = 0; i < 3; i++){
        for (j = 0; j < 3; j++){
            isWhite = 0; isBlack = 0;
            if (arr[i][j] == '#') isBlack++; else isWhite++;
            if (arr[i][j+1] == '#') isBlack++; else isWhite++;
            if (arr[i+1][j] == '#') isBlack++; else isWhite++;
            if (arr[i+1][j+1] == '#') isBlack++; else isWhite++;
            if ((isWhite >= 3) || (isBlack >= 3)) stat = 1;
            if (stat) break;
        }
        if (stat) break;
    }
    printf((stat)?"YES\n":"NO\n");
    return 0;
}

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

char arr[4][4];

int boardval(char * loc)
{
		if (*loc == '#')
				return 1;
		else return -1;
}

int main(void)
{
		for (int i = 0; i < 4; i++)
				for (int j = 0; j < 4; j++)
						scanf("%c ", &arr[i][j]);

		int sum;
		for (int i = 0; i < 3; i++)
				for (int j = 0; j < 3; j++){
						sum = 0;
						sum += (boardval(&arr[i][j]) + boardval(&arr[i+1][j]) + boardval(&arr[i][j+1]) + boardval(&arr[i+1][j+1]));
						if (abs(sum) >= 2){
								printf("YES\n");
								return 0;
						}
		}

		printf("NO\n");
		return 0;
}

#include <stdio.h>
#include <stdbool.h>

int main(void) {
    int n = 4;
    int m = 0;
    bool found = false;
    char arr[n][n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%c", *(arr + i) + j);
        }
        scanf("%c", &m);
    }

    for (int i = 0; i < (n - 1); i++) {
        for (int j = 0, k = 0; j < (n - 1); j++, k = 0) {
            for (int r = 0; r < 2; r++) {
                for (int c = 0; c < 2; c++) {
                    if (arr[i + r][j + c] == '.') {
                        k++;
                    }
                }
            }

            if (k != 2) {
                found = true;
                goto done;
            }
        }
    }

    done:

    if (found == true) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

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

int main()
{
	char **square;
	square=(char **)malloc(sizeof(char *)*4);
	int i,j;
	for(i=0;i<4;i++)
	{
		*(square+i)=(char *)malloc(sizeof(char)*4);
	}
	for(i=0;i<4;i++)
	{
		scanf(" %s",*(square+i));
	}
	//
	int *check=(int *)malloc(sizeof(int)*2);
	//in check...
	//position 1 will be used for #
	//and 2 for .
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			*(check)=*(check+1)=0;
			//# check
			if(square[i][j]=='#')
			{
				(*(check))++;
			}
			if(square[i][j+1]=='#')
			{
				(*(check))++;
			}
			if(square[i+1][j]=='#')
			{
				(*(check))++;
			}
			if(square[i+1][j+1]=='#')
			{
				(*(check))++;
			}
			// . check
			if(square[i][j]=='.')
			{
				(*(check+1))++;
			}
			if(square[i+1][j]=='.')
			{
				(*(check+1))++;
			}
			if(square[i][j+1]=='.')
			{
				(*(check+1))++;
			}
			if(square[i+1][j+1]=='.')
			{
				(*(check+1))++;
			}
			//checking possibility of passing
			if(*(check+1)==3 && *(check)==1 || *(check+1)==1 && *(check)==3 || *(check+1)==4 || *(check)==4)
			{
				printf("YES\n");
				return 0;
			}
		}
	}
	printf("NO\n");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main ()
{
    int tab[4][4]={0};
    int i,j,flag=0;
    char ch;

    for (i=0;i<4;i++){
        for(j=0;j<4;j++){
            scanf(" %c",&ch);
            if (ch=='#') tab[i][j]=1;
            else tab[i][j]=0;
        }
    }

    for (i=1;i<4;i++){
        for(j=1;j<4;j++){
                if (tab[i][j]+tab[i-1][j]+tab[i-1][j-1]+tab[i][j-1]!=2)
                        flag=1;
        }
    }
    if(flag==1) printf("YES");
    else printf("NO");
    return 0;
}

#include <stdio.h>
int test(char a[4][4],int i,int j){
	int count1=0,count2=0,k,l;
	for(k=0;k<2;k++){
		for(l=0;l<2;l++){
			if(a[i+k][j+l]=='#'){
				count1++;
			}
			else{
				count2++;
			}
		}
	}
	if(count1>=3){
		return 1;
	}
	else if(count2>=3){
		return 1;
	}
	else{
		return 0;
	}
}
int main(){
	int i,j;
	char arr[4][4];
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			scanf(" %c",&arr[i][j]);
			//printf("aa\n");
		}
	}

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			if(test(arr,i,j)){
				printf("YES\n");
				return 0;
			}
		}
	}
	printf("NO\n");
	return 0;
}

#include <stdio.h>
#include <string.h>
char s[100][100];
int main()
{
    int i,j,black=0,white=0,res,p=0,k=0;
    for(i=0;i<4;i++){
        scanf("%s",s[i]);
    }
    int x=0,y=0;
    while(1){
        for(i=x;i<(x+2);i++){
            for(j=y;j<(y+2);j++){
                if(s[i][j]=='#'){
                    black++;
                }
                else white++;
            }
        }
        if(black>=3 || white >=3){
            res=1;
            break;
        }
        else {
            black = 0;
            white =0;
        }
        k++;
        //if(k==2){
          //  k=0;
            y++;
        //}
        if(y==3){
            y=0;
            x=2;
            p++;
        }
        if(p==2){
            res=0;
            break;
        }
    }
    if(res) printf("YES");
    else printf("NO");

    return 0;
}

#include<stdio.h>
int search(int i,int j,char arr[4][4]){
    if((arr[i][j]==arr[i+1][j])){
        if((arr[i][j]==arr[i][j+1])||(arr[i+1][j]==arr[i+1][j+1])){
            return 1;
        }
        else{
            return 0;
        }
    }

    else if((arr[i][j]==arr[i][j+1])){
        if((arr[i][j]==arr[i+1][j])||(arr[i][j+1]==arr[i+1][j+1])){
            return 1;
        }
        else{
            return 0;
        }
    }
    else {
        return 0;
    }
}
int main(){
    char arr[4][4];
    int i,j;
    for(i=0;i<4;i++){
        for(j=0;j<4;j++){
            scanf("%c",&arr[i][j]);
        }
    }
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(search(i,j,arr)){
                printf("YES");
                return 0;
            }
        }
    }
    printf("NO");
    return 0;
}

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

int main()
{
     char arr[4][4];
     int flag=0;
     for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            scanf("%c",&arr[i][j]);

        }
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(arr[i][j]==arr[i][j+1]){
                if((arr[i][j]==arr[i+1][j])||(arr[i][j]==arr[i+1][j+1])){
                    flag=1;
                }
            }

        }
    }
    if(flag==1){
        printf("YES");
    }
    else{
        printf("NO");
    }

}

#include <stdio.h>

int main () {

	int lista[4][4];
	int i,j;
	char c;

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			scanf("%c",&c);
			if(c=='#'){
				lista[i][j]=1;
			}else{
				lista[i][j]=0;
			}
		}
		scanf("%c",&c);
		fflush(stdin);
	}

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			printf("%d",lista[i][j]);
		}
		printf("\n");
	}

	return 0;
}

#include<stdio.h>
#include<stdbool.h>

char tab[5][5];
bool contour(int i,int j);

int main()
{
    int k=0;
    int i,j;

    for(i=0;i<4;i++)scanf("%s",tab[i]);

//main
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if (contour(i,j)){printf("YES \n"); k++; break; }

        }
        if(k!=0)break;
    }
    if(k==0)printf("NO \n");

    return 0;
}

bool contour(int i,int j)
{
    if     ((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j])){return 1;}
    else if((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else if((tab[i][j]==tab[i+1][j])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else return 0;
}

#include<stdio.h>
int main(){
    int i,j,flag,count;
    char a[4][5];
    for(i=0;i<4;i++){
        scanf("%s",a[i]);
    }
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            count=0;
            flag=a[i][j];
            if(a[i+1][j]==flag){
                count++;
            }
            if(a[i][j+1]==flag){
                count++;
            }
            if(a[i+1][j+1]==flag){
                count++;
            }
            if(count>1){
                printf("YES");
                return 0;
            }
        }
    }
    printf("NO");
    return 0;
}

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

int check(int a[6][6]);

int main()
{
    int a[6][6] = {0};
    int i, j, k, t;
    int blank[16] = {0};
    char s[5];
    int m = 0;

    for(i = 1; i < 5; i++) {
        scanf("%s", s);
        for(j = 1; j < 5; j++){
            if(s[j] == '#')
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
    }
/*
    for(i = 1; i < 5; i++) {
        for(j = 1; j < 5; j++) {
            printf("%d  ", a[i][j]);
        }
        printf("\n");
    }
*/
    m = check(a);
    if(m == 1)
        printf("YES");
    else
        printf("NO");

    return 0;
}

int check(int a[6][6])
{
    int i, j, k, t;
    int result = 0;
    int big = 0;

    for(i = 1; i < 5; i++) {
        for(j = 1; j < 5; j++) {
            if(a[i][j] == 0) {
                if(a[i-1][j-1] || a[i-1][j+1] || a[i+1][j-1] || a[i+1][j+1]) {
                    if(a[i-1][j-1] == 1) { //northwest square
                        if(a[i-1][j] == 1 && a[i][j-1] == 1) {
                            result = 1;
                            return result;
                        }
                        else {
                            result = 0;
                            continue;
                        }
                    }
                    else {
                        if(a[i-1][j+1] == 1) { //northeast square
                            if(a[i-1][j] == 1 && a[i][j+1] == 1) {
                                result = 1;
                                return result;
                            }
                            else {
                                 result = 0;
                                 continue;
                            }
                        }
                        else {
                            if(a[i+1][j-1] == 1) { //southwest square
                                if(a[i][j-1] == 1 && a[i+1][j] == 1) {
                                    result = 1;
                                    return result;
                                }
                                else {
                                    result = 0;
                                    continue;
                                }
                            }
                            else {
                                if(a[i+1][j+1] == 1) { // southeast square
                                    if(a[i][j] == 1 && a[i][j+1] == 1) {
                                        result = 1;
                                        return result;
                                    }
                                    else {
                                        result = 0;
                                        return result;
                                    }
                                }
                            }
                        }

                    }
                }
                else {
                    result = 0;
                    return result;
                }
            }
        }
    }

    return result;
}

#include<stdio.h>
int main()
{
  char a[16],i;
  int c=0;
       for(i=0;i<16;i++)
       {
            scanf("%c",&a[i]);
       }
       for(i=0;i<12;i++)
       {
            if(a[i]==a[i+4]||a[i+1]==a[i+5])
            {
                 c=1;
                 break;
            }

            else
            c=0;
       }
       if(c==1)
       printf("Yes");
       else
       printf("No");
return 0;
}

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

int sumar(int a,int b,int c,int d){

	int k;

	k=a+b+c+d;

	if(k>=3){
		k=0;
	}else{
		k=1;
	}

	return k;
}

int main () {

	int lista[4][4];
	int i,j,k;
	char * p;

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			lista[i][j]=getchar();
			if(lista[i][j]==46){
				lista[i][j]=0;
			}else{
				lista[i][j]=1;
			}
		}
		getchar();
		fflush(stdin);
	}

	p=(char *)malloc(sizeof(char)*4);
	p="NO";

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			k=sumar(lista[i][j],lista[i+1][j],lista[i][j+1],lista[i+1][j+1]);
			if(k==0){
				p="YES";
				break;
			}
		}
	}

	puts(p);

	return 0;
}

#include <stdio.h>
#include <stdbool.h>

int main(void) {
    int n = 4;
    int m = 0;
    bool found = false;
    char arr[n][n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%c", *(arr + i) + j);
        }
        scanf("%c", &m);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0, k = 0; j < n; j++, k = 0) {
            if (arr[i][j] == '#') {
                k++;
            }
            if (i > 0 && arr[i - 1][j] == '#') {
                k++;
            }
            if (j < (n - 1) && arr[i][j + 1] == '#') {
                k++;
            }
            if (j < (n - 1) && i > 0 && arr[i - 1][j + 1] == '#') {
                k++;
            }

            if (k == 3) {
                found = true;
                goto done;
            }
        }
    }

    done:

    if (found == true) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

#include<stdio.h>
int main()
{
    //freopen("in.txt","r",stdin);
    char p[5][5],c;
    int n,i,j;
    for(i=0;i<4;i++)
       scanf("%s",p[i]);
    for(i=0;i<3;i++)
       for(j=0;j<3;j++)
       {
           n=0;
           c=p[i][j];
           if(c==p[i][j+1])
                n++;
           if(c==p[i+1][j])
                n++;
           if(c==p[i+1][j+1])
                n++;
           if(n>=2)
                goto loop;
       }
    loop:if(n>=2)
             printf("YES\n");
         else
             printf("NO\n");
    return 0;
}

#include<stdio.h>
int main()
{
    char a[4][4];
    int count = 0,flag = 0,i,j;
    for(i=0;i<4;i++)
    {
        for(j=0;j<4;j++)
        {
            scanf(" %c",&a[i][j]);
        }
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            count = 0;
            if(a[i][j] == a[i+1][j])
            count++;
            if(a[i][j] == a[i][j+1])
            count++;
            if(a[i][j] == a[i+1][j+1])
            count++;
            if(count>=2)
            {
                flag = 1;
                goto hell;
            }
        }
    }
    hell:
    if(flag == 1)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

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

int main()
{
    char square[4][5];
    int i;
    for(i=0;i<4;i++)
        scanf("%s",square[i]);
    for(i=0;i<4;i++)
    {
        int j;
        for(j=0;j<4;j++)
        {
            if(((square[i][j]==square[i][j+1])&&((square[i][j]==square[i+1][j])||(square[i][j]==square[i+1][j+1])))||((square[i+1][j]==square[i+1][j+1])&&((square[i+1][j]==square[i][j])||(square[i+1][j]==square[i][j+1]))))
            {
                printf("YES\n");
                return 0;
            }
        }
    }
    printf("NO\n");
}

#include<stdio.h>

#define ROW 4
#define COL 4

/*
    .X
    XX
    If any 3 of the 4 squares are the same colour then we can make a square
 */

//Counts
int count (int g[ROW][COL], int r, int c){
    int n=0, i, j;

    for (i=r; i<2; i++)
        for (j=c; j<2; j++)
            if (g[i][j] == 1)
                n++;

    return n;
}

int main (){

    int grid[ROW][COL] = {{0}};
    int i, j, c;
    int sq = 0;

    for (i=0; i<ROW; i++)
        for (j=0; j<COL; j++){
            c = getchar();
            if (c == '#'){
                grid[i][j] = 1;
            } else if (c == '.') {
               grid[i][j] = 0;
            } else {
                //Invalid input
                //Get next char without exiting loop
                j--;
            }
        }

    //Analyse the grid
    for (i=0; i<ROW-1; i++){
        for (j=0; j<COL-1; j++){
            if (count(grid, i, j) != 2)
                sq = 1;
        }
    }

    if (sq == 1)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int check_repaint(char arr[][5])
{
int i ,j;
  for (i=0;i<5;i++)
  for(j=0;j<5;j++)
  {
   if(arr[i][j]==arr[i][j+1]&&arr[i][j]==arr[i+1][j+1]&&arr[i][j]==arr[i+1][j])return 1 ;
   if(arr[i][j]==arr[i][j-1]&&arr[i][j]==arr[i+1][j-1]&&arr[i][j]==arr[i+1][j])return 1 ;
   if(arr[i][j]=='.')
   arr[i][j]='#';
   else
   arr[i][j]='.';
  if(arr[i][j]==arr[i][j+1]&&arr[i][j]==arr[i+1][j+1]&&arr[i][j]==arr[i+1][j])return 1 ;
    if(arr[i][j]==arr[i][j-1]&&arr[i][j]==arr[i+1][j-1]&&arr[i][j]==arr[i+1][j])return 1 ;
  if(arr[i][j]=='.')
    arr[i][j]='#';
   else
    arr[i][j]='.';
  }
  return 0 ;
}
int main()
{
   char arr[5][5];
   int i;
   for (i=1;i<5;i++)
    scanf("%s",arr[i]);
    i=0;
if(check_repaint(arr))
printf("YES");
else
printf("NO");
    return 0;
}

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

int sumar(int a,int b,int c,int d){

	a=a+b+c+d;

	if(a>=3){
		a=0;
	}else{
		a=1;
	}

	return a;
}

int main () {

	int lista[4][4];
	int i,j,k;
	char * p;

	p=(char *)malloc(sizeof(char)*4);

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			lista[i][j]=getchar();
			if(lista[i][j]==46){
				lista[i][j]=0;
			}else{
				lista[i][j]=1;
			}
		}
		getchar();
		fflush(stdin);
	}

	p="NO";

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			k=sumar(lista[i][j],lista[i+1][j],lista[i][j+1],lista[i+1][j+1]);
			if(k==0){
				p="YES";
				break;
			}
		}
	}

	puts(p);

	return 0;
}

#include<stdio.h>
int main(){
    char squareArray[4][4];
    int i,flag=0,j,count;
    for(i=0;i<4;i++){
        scanf("%s",squareArray[i]);
    }
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            count = 0;
            if(squareArray[i][j]=='#')count++;
            if(squareArray[i][j+1]=='#')count++;
            if(squareArray[i+1][j]=='#')count++;
            if(squareArray[i+1][j+1]=='#')count++;
            if(count>=3){
                flag=1;
                break;
            }
        }
        if(flag==1)break;
    }
    if(flag==1)printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>

char grid[4][4];

int isBlack(int i,int j)
{
    if(grid[i][j] == '#')
        return 1;
    else
        return 0;
}

int find(int i,int j)
{
    if(isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && !isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && isBlack(i,j+1) && !isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    return 0;
}

int solve()
{
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(find(i,j)==1)
                return 1;
        }
    }
    return 0;
}

int main()
{
    int i,j;
    char s[5];
    for(i=0;i<4;i++)
    {
        scanf("%s",s);
        for(j=0;j<4;j++)
            grid[i][j] = s[j];
    }

    if(solve()==1)
        printf("YES");
    else
        printf("NO");
    return 0;
}

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

int check(int a[6][6]);

int main()
{
    int a[6][6] = {0};
    int i, j, k, t;
    char s[5];
    int m;

    for(i = 1; i < 5; i++) {
        scanf("%s", s);
        for(j = 1; j < 5; j++){
            if(s[j] == '#')
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
    }
/*
    for(i = 1; i < 5; i++) {
        for(j = 1; j < 5; j++) {
            printf("%d  ", a[i][j]);
        }
        printf("\n");
    }
*/
    m = check(a);
    if(m == 1)
        printf("YES");
    else
        printf("NO");

    return 0;
}

int check(int a[6][6])
{
    int i, j, k, t;
    int tmp = 0;

    for(i = 1; i < 4; i++) {
        for(j = 1; j < 4; j++) {
            tmp = a[i][j] + a[i][j+1] + a[i+1][j] + a[i+1][j+1];
            if (tmp == 2)
                return 1;
            else
                continue;
        }
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int check_repaint(char arr[][4])
{
int i ,j;
  for (i=0;i<4;i++)
  for(j=0;j<4;j++)
  {
  if(arr[i][j]=='.')
  arr[i][j]='#';
  else
  arr[i][j]='.';
  if(arr[i][j]==arr[i][j+1]&&arr[i][j]==arr[i+1][j+1]&&arr[i][j]==arr[i+1][j])return 1 ;
  if(arr[i][j]==arr[i][j-1]&&arr[i][j]==arr[i+1][j-1]&&arr[i][j]==arr[i+1][j])return 1 ;
  if(arr[i][j]==arr[i][j+1]&&arr[i][j]==arr[i-1][j+1]&&arr[i][j]==arr[i-1][j])return 1 ;
  if(arr[i][j]==arr[i][j-1]&&arr[i][j]==arr[i-1][j-1]&&arr[i][j]==arr[i-1][j])return 1 ;
  if(arr[i][j]=='.')
    arr[i][j]='#';
   else
    arr[i][j]='.';
  }
  return 0 ;
}
int main()
{
   char arr[4][4];
   int i;
   for (i=0;i<4;i++)
    scanf("%s",arr[i]);
if(check_repaint(arr))
printf("YES");
else
printf("NO");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int check_repaint(char arr[][5])
{
int i ,j;
  for (i=1;i<5;i++)
  for(j=1;j<5;j++)
  {
   if(arr[i][j]==arr[i][j+1]&&arr[i][j]==arr[i+1][j+1]&&arr[i][j]==arr[i+1][j])return 1 ;
   if(arr[i][j]==arr[i][j-1]&&arr[i][j]==arr[i+1][j-1]&&arr[i][j]==arr[i+1][j])return 1 ;
   if(arr[i][j]=='.')
   arr[i][j]='#';
   else
   arr[i][j]='.';
  if(arr[i][j]==arr[i][j+1]&&arr[i][j]==arr[i+1][j+1]&&arr[i][j]==arr[i+1][j])return 1 ;
    if(arr[i][j]==arr[i][j-1]&&arr[i][j]==arr[i+1][j-1]&&arr[i][j]==arr[i+1][j])return 1 ;
  if(arr[i][j]=='.')
    arr[i][j]='#';
   else
    arr[i][j]='.';
  }
  return 0 ;
}
int main()
{
   char arr[5][5];
   int i;
   for (i=1;i<5;i++)
    scanf("%s",arr[i]);
if(check_repaint(arr))
printf("YES");
else
printf("NO");
    return 0;
}

#include <stdio.h>

int main () {

	int lista[4][4];
	int i,j;

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			lista[i][j]=getchar();
		}
		getchar();
		fflush(stdin);
	}

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			printf("%d",lista[i][j]);
		}
		printf("\n");
	}

	return 0;
}

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

int main()
{
    char square[4][5];
    int i;
    for(i=0;i<4;i++)
        scanf("%s",square[i]);
    for(i=0;i<4;i++)
    {
        int j;
        for(j=0;j<4;j++)
        {
            if((square[i][j]==square[i][j+1])&&((square[i][j]==square[i+1][j])||(square[i][j]==square[i+1][j+1])))
            {
                printf("YES\n");
                return 0;
            }
            if((square[i+1][j]==square[i+1][j+1])&&((square[i+1][j]==square[i][j])||(square[i+1][j]==square[i][j+1])))
            {
                printf("YES\n");
                return 0;
            }
        }
    }
    printf("NO\n");
}


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

int main()
{
    char table[3], hands[3];
    int s = 0;
    scanf("%s", table);

        for(int i = 0; i < 5; i++)
        {
           s = 0;
           scanf("%s", hands);
           if(hands[s] == table[s] || hands[s+1] == table[s+1]) {printf("YES"); return 0;}
           else continue;
        }
    printf("NO ");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,count=0;
    char str1[2],str2[100];
    scanf("%s",str1);
    getchar();
        gets(str2);
        for(i=0;i<strlen(str2);i++)
        {
            if(str2[i]==str1[0] || str2[i]==str1[1])
                count++;
        }
        if(count>0)
            printf("YES");
        else
            printf("NO");
        return 0;

}

#include<stdio.h>
int main(void)
{
	char b[2][3];
	char a[6][3];
	int x,y;
	int flag=0;

	scanf("%c%c",&b[1][1],&b[1][2]);
	getchar();

	for(x=0;x<5;x++)
	{
		scanf("%c%c",&a[x][1],&a[x][2]);
		getchar();
		if(a[x][1]==b[1][1]) flag=1;
		if(a[x][2]==b[1][2]) flag=1;
		if(flag==1) break;
	}

	if(flag==1) printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include<stdio.h>
int main()
{
int n=0;
char f,l,q;
scanf("%c",&f);
scanf("%c",&l);
scanf("%c",&q);
char a,b,c;
while(n<5)
{
scanf("%c",&a);
scanf("%c",&b);
scanf("%c",&c);
if((f==a)||(l==b))
{
printf("yes\n");
return 0;
}
n++;
}
printf("no\n");
return 0;
}

#include<stdio.h>
int main(){
char a,b,w;
int count=0;
scanf("%c%c%c",&a,&b,&w);
for(int i=0;i<5;i++){
char c,d;
scanf("%c%c%c",&c,&d,&w);
if(a==c || b==d){
	printf("YES");
	break;}
else
	count++;
}
if(count==5)
	printf("NO");
return 0;
}

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

int main()
{
	char a[5];
	char b[50];

	gets(a);
	gets(b);

	for(int i=0;a[i]!='\0';i++)
	{
		for(int j=0;b[j]!='\0';j++)
		{
			if(a[i]==b[j])
			{
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");

	return 0;
}

#include<stdio.h>
int main()
{
    char a[3],result;
    scanf("%s",&a);
    char b[3],b1[3],b2[3],b3[3],b4[3];
    scanf("%s %s %s %s %s",&b,&b1,&b2,&b3,&b4);
    int i=0;
    while(a[i]!=0)
    {
        result=a[i];
        int j=0;
        char count;
        while(b[j]!=0)
        {
            count=b[j];
            if(result==count)
            {
                printf("YES\n");
                exit(0);
            }
            j=j+1;
        }
        int k=0;
        while(b1[k]!=0)
        {
            count=b1[k];
            if(result==count)
            {
                printf("YES\n");
                exit(0);
            }
            k=k+1;
        }
        int l=0;
        while(b2[l]!=0)
        {
            count=b2[l];
            if(result==count)
            {
                printf("YES\n");
                exit(0);
            }
            l=l+1;
        }
        int m=0;
        while(b3[m]!=0)
        {
            count=b3[m];
            if(result==count)
            {
                printf("YES\n");
                exit(0);
            }
            m=m+1;
        }
        int n=0;
        while(b4[n]!=0)
        {
            count=b4[n];
            if(result==count)
            {
                printf("YES\n");
                exit(0);
            }
            n=n+1;
        }
        i=i+1;

    }
    printf("NO\n");
}

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

void fchaine(char *string)
{
    int i,n;
    char L;

    n = strlen(string);

    for(i=0;i<n/2;i++)
    {
        L = string[i];
        string[i] = string[n-i-1];
        string[n-i-1] = L;
    }
}

int main(void)

{
    int c,i;
    char c1[10],invc1[10];
    char c2[10][10],invc2[10][10];

    scanf("%s",c1);

    strcpy(invc1,c1);
    fchaine(invc1);

    c=0;

    for (i=0;i<5;i++)
    {
        scanf ("%s",c2[i]);

        if (strncmp(c1,c2[i],1)==0)
            c++;

        strcpy(invc2[i],c2[i]);
        fchaine(invc2[i]);

        if (strncmp(invc1,invc2[i],1)==0)
            c++;
    }

    if (c==0)
        printf ("NO");
    if (c>0)
        printf ("YES");

}

#include<stdio.h>
int main()
{
char str[2],str1[5];
int count=0,i,j,p;
scanf("%s",str);
for(i=0;i<5;i++)
{
    scanf("%s",str1);
    p=0;
    for(j=0;j<2;j++,p++)
    {
    if(str[p]==str1[j])
    count=count+1;
    }
    }
    if(count>0)
    printf("Yes");
    else
    printf("No");
return 0;
}

#include<stdio.h>
int main()
{
    char ch[2],c[2];
    scanf("%s",ch);
    int n=5,count=0;
    while(n--)
    {
        scanf("%s",c);
        if((c[0]==ch[0])||(c[1]==ch[1]))
        count++;
    }
    if(count>0)
    printf("YES");
    else
    printf("NO");
    return 0;
}

#include <stdio.h>

int main(){
    char tab1[3] = {0};
    char tab2[3] = {0};
    scanf("%s", tab1);

    for(int i=0; i<5; i++)
    {
        scanf("%s", tab2);
        if(tab1[0] == tab2[0] || tab1[1] == tab2[1])
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>

int main()
{
    char name[3], test[3];
    int i, j, a, length, count = 0,b;

    scanf("%s", name);

    for(i=1; i<=5; i++)
    {
        scanf("%s", test);

        if(test[0] == name[0])
        {

            count = 1;
        }
        else if((test[0] == name[0]) && (test[1] == name[1]))
        {

            count = 1;
        }
        else if(test[1] == name[1])
        {
            count = 1;

        }
    }

    if(count == 1)
    {

        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }

    return 0;
}

#include<stdio.h>
main()
{
	int n, i, c = 0, d = 0;
	char a[2], b[14];
	gets(a);
	gets(b);
	for (i = 0; i < 14; i++)
	{
		if (a[0] == b[i] || a[1] == b[i])
			c++;
	}
	if (c > 0)
		printf("YES\n");
	else
		printf("NO\n");
}

#include<stdio.h>
#include<string.h>
int main()

{
    int i,l,flag=0;
    char s[12];
    char a,b;
    scanf("%c%c",&a,&b);
    scanf("\n");
    scanf("%[^\n]s",&s);
    l=strlen(s);
    for(i=0;i<=l-1;i++)
    {
        if(a==s[i]||b==s[i])
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    printf("YES");
    else printf("NO");
    return 0;
}

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

int main()
{
    int i,x=0;
    char F[2] ;
    char H[2];

    scanf("%s" ,F );

    for (i=0 ;i<=4 ;i++)
    {
        scanf("%s", H);
         if ((H[0]==F[0]) || (H[1]==F[1]))

               x++;

    }
    if (x>0)
            printf("Yes");

      else
           {
            printf("No");
           }

    return 0;
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int main(){
int t=0;
char a[3],b[3];
scanf("%s",&a);
for(int i=1;i<=5;i++){
scanf("%s",&b);
if((b[0]==a[0])||(b[1]==a[1]))
    {
        t++;
    }
}
if(t==0){
    printf("NO");
}
else
    printf("YES");
return 0;
}

#include<stdio.h>
int main(){
	char a,b,c,d;
	scanf("%c%c\n",&a,&b);
	int i,f;
	f=0;
	for(i=0;i<5;i++){
	scanf("%c%c ",&c,&d);
	if(a==c||b==d){
		f=1;
	}
	}
	if(f==1){
	printf("YES");
	}
	else{
	printf("NO");
	}
	return 0;
}

#include<stdio.h>
#include<string.h>
int main(void)
{
    char r, s;
    char a, b;
    int flag = 0;
    scanf("%c%c", &a, &b);
    getchar();
    for(int i = 0; i < 5; i++)
    {
        scanf("%c%c", &r, &s);
        getchar();
        if(r == a || b == s) flag = 1;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

#include<stdio.h>
int main()
{
	char a[5],b[5];
	int i,c=0;
	scanf("%s",b);
	for(i=0;i<5;i++)
	{
		scanf("%s",a);
		if (a[0]==b[0]||a[1]==b[1])
			c=1;
	}
	if(c==1)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

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

int main()
{
    char s[2];
    char a[2];
    char s1[2];
    scanf("%s",s);
    a[1]=s[0];
    a[2]=s[1];
    int i,count=0;
    for(i=1;i<=5;i++){
        scanf("%s",s1);
        if(a[1]==s1[0])
            count=1;
        if(a[2]==s1[1])
            count=1;
    }
    if(count)
        printf("YES");
    else
        printf("NO");
    return 0;
}

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

int main()
{

	int i = 0, j = 0;
	char table[2];
	char hand[15];
	for(i = 0;i<2;i++)
	{
		table[i]= 0;
	}
	for(j = 0;j<15;j++)
	{
		table[j]= 0;
	}
	gets(table);
	gets(hand);

	for (j = 0; j < 2; j++)
	{
		for (i = 0; i < 15; i++)
		{
			if (table[j] == hand[i])
			{
				printf("YES");
				exit(0);
			}

		}

	}
	printf("NO");
	return 0;
}

#include <stdio.h>

int main()
{
	char orta[3];
	char el1[3];
	char el2[3];
	char el3[3];
	char el4[3];
	char el5[3];

	scanf("%s", orta);
	scanf("%s", el1);
	scanf("%s", el2);
	scanf("%s", el3);
	scanf("%s", el4);
	scanf("%s", el5);

	if (el1[0] == orta[0] || el1[1] == orta[1]){
		printf("YES");
		return 0;
	}

	if (el2[0] == orta[0] || el2[1] == orta[1]){
		printf("YES");
		return 0;
	}

	if (el3[0] == orta[0] || el3[1] == orta[1]){
		printf("YES");
		return 0;
	}

	if (el4[0] == orta[0] || el4[1] == orta[1]){
		printf("YES");
		return 0;
	}

	if (el5[0] == orta[0] || el5[1] == orta[1]){
		printf("YES");
		return 0;
	}

	else{
		printf("NO");
	}

}

 #include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct liste{
    char name[30];
    struct liste *next;
};
typedef struct liste *liste ;
liste creation(int n){
    liste head,tmp,pt;
         head=malloc(sizeof(struct liste));
         scanf("%s",head->name);
        if(strlen(head->name)!=2)exit(EXIT_FAILURE);
            head->next=NULL;
            pt=head;
     for(int i=1;i<n;i++){
           tmp=malloc(sizeof(struct liste));
           scanf("%s",tmp->name);
           if(strlen(head->name)!=2)exit(EXIT_FAILURE);
           tmp->next=NULL;
           pt->next=tmp;
           pt=tmp;
     }
      return head;

}
int traitement(char card[],liste L){
    int i=0;

liste p;

    do{
        p=L;
             while(p){
                if(card[i]==p->name[i]){
                 printf("YES");
                return 0;
                                }
                                p=p->next;
             }
             i++;

    }while(i<2);

    printf("NO");
}
 int main(){
char card[2];
liste L;
 scanf("%s",card);
 if(strlen(card)!=2)return 0;
 L=creation(5);
   traitement(card,L);

}

#include<stdio.h>
int main()
{
int i,b=0;
	char s[5],d[5];

	scanf("%s",d);
	for(int j=0;j<5;j++)
	    {
		   scanf("%s",s);
	       if(s[0]==d[0])
	        {
		       b++;
		         break;
		     }

	    else
	   {
		  if(s[1]==d[1])
		  {
		   b++;
		   break;

     	}
    }
   }

	if(b>0)
	printf("YES");
	else
	printf("NO");

	return 0;
}

#include <stdio.h>
#include <conio.h>
#include <math.h>
int main ()
{
	char tc[3] , hc[3] ;
	int c = 0 ;
	scanf (" %s " , tc ) ;
	for ( int i = 1 ; i <= 5 ; i++ )
	{
		scanf( " %s " , hc) ;
		if ( tc[0] == hc[0] || tc[1] == hc[1] )
		{
			c++ ;
		}
	}
	if ( c == 0 )
		printf("NO");
	else
		printf("YES");
	return 0 ;
}

typedef struct {
    char rank,suit;
} card;
int main() {
    card c1, c2[5];
    scanf("%c%c",&c1.rank,&c1.suit);
    int i;
    for(i=0;i<5;i++) {
        scanf("%*c%c%c",&c2[i].rank,&c2[i].suit);
        if(c1.rank==c2[i].rank || c1.suit==c2[i].suit) {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>
int main()
{
	int c=1;
		char first,last;
	scanf("%c",&first);
	scanf("%c",&last);
	while(c<=5)
	{
		char a,b,sp;
		scanf("%c",&sp);
		scanf("%c",&a);
		scanf("%c",&b);
		if((a==first)||(b==last))
		{
			printf("YES");
			return 0;
		}
		c++;
	}
	printf("NO");
	return 0;
}

#include<stdio.h>
#include<strings.h>
#include<stdlib.h>
int main()
{
    int i,j;
    char s[3];
    char t[6][2];
    scanf("%s",s);
    for(i=0;i<5;i++)
    scanf("%s",t[i]);
    for(j=0;j<5;j++)
    {
      if(s[0]==t[j][0]||s[1]==t[j][1])
      {printf("YES");
      return 0;
      }

    }
    printf("NO");
    return 0;
}

#include<stdio.h>
int main()
{
    char a[3],b[3];
    int c=0;
    scanf("%s",a);
    for(int i=0;i<5;i++)
    {
        scanf("%s",b);
        if(a[0]==b[0] || a[1]==b[1])
            c++;
    }
    if(c>0)
        printf("YES");
    else
    {
        printf("NO");
    }

}

#include <stdio.h>
int main() {
	char s[2],k[2];int m;
	m=0;
	scanf("%s",s);
	printf("\n");
	for(int i=1;i<=5;i++)
	{
		scanf("%s ",k);
		if((k[0]== s[0])||(k[1]==s[1]))
		m=1;
		}
		if(m==1)
		printf("YES");
		else
		printf("NO");
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{ int c=0,n=5;
   char a[3],b[3];
				scanf("%s",a);
				while(n--)
				{
			scanf("%s",b);
								if(a[0]==b[0]||a[1]==b[1])

												c=1;
				}

c?printf("YES"):printf("NO");
return 0;
}

#include <stdio.h>
int main()
{
  char a[2];
  scanf("%s",a);
  char b[2];
  int i,flag=0;
  for(i=1;i<=5;i++)
  {
    scanf("%s",b);
    if(a[0]==b[0] || a[1]==b[1])
    {
      flag=1;
      break;
    }
  }
if(flag==1)
  printf("YES");
else
  printf("NO");

}

#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,count=0;
    char str[2],str_[2];
    scanf("%c%c", &str_[0], &str_[1]);
    for(i=1;i<=5;i++)
    {
        scanf(" %c%c", &str[0], &str[1]);

        if(str[0]==str_[0] || str[1]==str_[1])
        {
            count++;
        }
    }
    if(count>=1)
            printf("YES\n");
            else
                printf("No\n");

    return 0;
}

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

int main()
{
    char a[2];int temp=0;
    scanf("%s",a);
    char n[5][2];
    for(int i=0;i<5;i++)
    {
        scanf("%s",n[i]);
    }
    for(int i=0;i<5;i++)
    {

        if(a[0]==n[i][0] || a[1]==n[i][1])
        {
            temp++;break;
        }
    }
    if(temp>0)
    {

        printf("YES");

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

#include<stdio.h>
#include<string.h>
char str[100];
int main()
{
    char table[3],card[3];
    int n;
    scanf("%s", table);
    for(n=0;n<5;n++)
    {
        scanf("%s", card);
        strcat(str, card);
    }
    for(n=0;str[n];n++)
    {
        if(table[0]==str[n] || table[1]==str[n])
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
}

#include<stdio.h>
int main()
{
	char a[2];
	char b[5];
	int i,cnt=0;
	scanf("%s",a);
	for(i=0;i<5;i++)
	{
		scanf("%s",b);
		if(a[0]==b[0]||a[1]==b[1])
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

#include<stdio.h>
int main()
{
    int j,c=0;
    char ac[2],pn[2];
        scanf("%s",&ac);
        for(j=0;j<5;j++)
        {
            scanf("%s",&pn);
            if(ac[0]==pn[0] || ac[1]==pn[1])
            c++;
        }

    if(c>0)
        printf("YES");
    else
        printf("NO");
    return 0;

}

#include<stdio.h>
int main()
{
    int i,j,n;
    char a[3];
    char b[3];
    scanf("%s",a);
    for(i=0;i<5;i++){
        scanf("%s",b);

        if(a[0]==b[0] || a[1]==b[1]){
            printf("YES\n");
            return 0;
        }
    }

    printf("NO\n");
    return 0;
}

#include<stdio.h>
int main(){
    int n = 5;
    char a,b,c,d;
    scanf("%c%c\n",&a,&c);
    while(n--){
        scanf("%c%c ",&b,&d);
        if(a == b || c == d){
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>
int main()
{
int i,cnt=0;
char a[2];
char b[2];
scanf("%s",a);
for(i=0;i<5;i++)
{
scanf("%s",b);
if(a[0]==b[0]||a[1]==b[1]){
cnt=1;
break;
}
}
if(cnt==1)
printf("YES");
else
printf("NO");
}

#include<stdio.h>
int main(){
	char t[3],h[3];
	int i,count = 0;
	scanf("%s",t);
	for(i=0;i<5;i++){
		scanf("%s",h);
		if(h[0]==t[0] || h[1]==t[1]){
			count = 1;
		}
	}
	 if(count == 1){
	     printf("YES");
	 }else {
	      printf("NO");
	 }

}

#include<stdio.h>

int main()
{
	char target[2],mine[2];
	int j,i,k=0;

	gets(target);

	for (i = 0; i < 5; ++i)
	{

		scanf("%s",mine);

		if(k==0 && (target[0]==mine[0] || target[1]==mine[1]))
		{
			k=1;
		}
	}

	if(k)
		printf("YES");
	else
		printf("NO");
}

#include<stdio.h>
int main()

{
    int i,count=0;
   char s[3],a[3];
   scanf("%s",s);
   for(i=0;i<5;i++)
   {
     scanf("%s",a);
     if(s[0]==a[0]||s[1]==a[1])
     {
         count=1;
     }
   }
   if(count)
   {
       printf("YES");
   }
   else
   {
       printf("NO");
   }
   return 0;

}

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

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}

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

int main()
{
    char name[3], test[3], ans[] = "23456789TJQKA";
    int i, j, a, length, count = 0,b;

    length = strlen(ans);

    scanf("%s", name);

    for(i=1; i<=5; i++)
    {
        scanf("%s", test);

        if(test[0] == name[0]){

            count = 1;
        }
        else if(test[1] == name[1]){

            for(j=0; j<length; j++){

                if( (name[0] == ans[j])){

                    a = (j+1);
                }
                if(test[0] == ans[j]){

                    b = (j+1);
                }
            }

            if(b>=a){

                count = 1;
            }
        }
    }

    if(count == 1){

        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}

#include <stdio.h>

int main() {
	char T[3];
	printf("please Enter");
	scanf("%s", T);
	char hand[5][3];
	int i;
	int flag=1;
	for(i=0;i<5;i++){
		scanf("%s", hand[i]);
	}
	for(i=0;i<5;i++){
		if((hand[i][0]==T[0] )||(hand[i][1]==T[1] )){
			printf("YES");
			flag=0;
			break;

		}

	}
	if(flag){
		printf("NO");
	}
}

#include<stdio.h>
int main()
{
int n=0;
char f,l,q;
scanf("%s",&f);
scanf("%s",&l);
char a,b,c;
while(n<5)
{
scanf("%s",&a);
scanf("%s",&b);
scanf("%s",&c);
n++;
}
if((f==b)||(l==c))
{
printf("YES");
}
else
{
printf("NO");
}
}

#include<stdio.h>
#include<string.h>
int main(){
char a[2];
char b[2];
gets(a);
int i,sum=0;
for(i=1;i<6;i++){
gets(b);
if((a[0]==b[0])||(a[1]==b[1]))
{
    sum++;
}
else
{
    continue;
}
}
if(sum>0)
{
    printf("YES");
}
else{
    printf("NO");
}
return 0;
}

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

int main()
{

	int i, j;
	char temp;
	char table[2] = { 0 };
	char hand[15] = { 0 };
	gets(table);
	gets(hand);

	for (j = 0; j < 2; j++)
	{
		temp = table[j];
		for (i = 0; i < 15; i++)
		{
			if (temp == hand[i])
			{
				printf("YES");
				break;

			}
			else
			{
				printf("NO");
				break;

			}
			break;
		}
		break;

	}

	return 0;

}

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

int main()
{
    char s[2];
    char a[2];
    char s1[2];
    scanf("%s",&s);
    s[0]==a[0];
    s[1]==a[0];
    int i,count;
    for(i=1;i<=2;i++){
        scanf("%s",s1);
        if(s1[0]==a[0])
        {
            count=1;
        }
        else if(s1[1]==a[1])
        {
            count=1;
        }
    }
    if(count)
        printf("YES");
    else
        printf("NO");
    return 0;
}

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

// <<<<< Macros <<<<<
#define BUFFERSIZE 255
#define BUFFERSIZEREAD BUFFERSIZE - 1
#define STACKSIZE 4
#define STACKSIZEREAD STACKSIZE - 1
// >>>>> Macros >>>>>

// <<<<< Preparations <<<<<
#ifdef __unix__
void fflush_for_linux() {
    /*
     * This will work like "fflush()" on stdin, because the normal one doesn't work on linux.
     */

    int character;
    do {
        character = getchar();
    } while (character != '\n' && character != EOF);
}
#endif
// >>>>> Preparations >>>>>

// <<<<< Declarations <<<<<
short same_suit(const char *buffer, char suit_value);
short same_rank(const char *buffer, char rank_value);
// >>>>> Declarations >>>>>

int main() {

    char buffer[BUFFERSIZE];
    char stack[STACKSIZE];

    fgets(stack, STACKSIZEREAD, stdin);

#ifdef __unix__
    fflush_for_linux();
#else
    fflush(stdin);
#endif

    fgets(buffer, BUFFERSIZEREAD, stdin);

    if (same_suit(buffer, stack[1]) == EXIT_SUCCESS
        || same_rank(buffer, stack[0]) == EXIT_SUCCESS)
        printf("YES\n");
    else
        printf("NO\n");

    return EXIT_SUCCESS;
}

short same_suit(const char *buffer, char suit_value) {

    register short index = 0;

    while (buffer[index] != '\0') {

        if (buffer[index++] == suit_value)
            return EXIT_SUCCESS;
    }

    // Couldn't find the same suit
    return EXIT_FAILURE;
}

short same_rank(const char *buffer, char rank_value) {

    register short index = 0;

    while (buffer[index] != '\0') {

        if (buffer[index++] == rank_value)
            return EXIT_SUCCESS;
    }

    return EXIT_FAILURE;

}

#include <stdio.h>
#include <stdbool.h>
int main (void)
{
	bool test = false ;
	char card[2] , hand_cards[10];
	int i,x ;
	gets(card);
	gets(hand_cards);
	for(i=0 ; i<2 ; i++)
	{
		for(x=0; x<10 ; x++)
		{
		if(card[i]== hand_cards[x])
		{
			test = true ;
			break ;
		}
		}
	}
	if (test)
		printf("yes");
	else
		printf("no");

}

#include <stdio.h>
#include <stdbool.h>
int main (void)
{
	bool test = false ;
	char card[2] , hand_cards[20];
	int i,x ;
	scanf("%s",card);
	scanf("%s",hand_cards);
	for(i=0 ; i<2 ; i++)
	{
		for(x=0; x<10 ; x++)
		{
		if(card[i]== hand_cards[x])
		{
			test = true ;
			break ;
		}
		}
	}
	if (test)
		printf("yes");
	else
		printf("no");

}

#include<stdio.h>
int main()
{
    int i,j,f;
    char ch[5],s[3];
    scanf("%s",&ch);
   for(i=0;i<5;i++)
   {
        scanf("%s",&s);
        if((ch[0]==s[0])||(ch[1]==s[1]))
            f=1;}

    if(f==1)
        printf("YES");
    else
        printf("NO");

return 0;
}

#include<stdio.h>
#include<string.h>
int main(void)
{
    char a[2], b[2];
    int flag = 0, i;
    gets(a);
    for(i = 0; i < 5; i++)
    {
        gets(b);
       // printf("%s\n", b);
        if(b[0] == a[0] || b[1] == a[1])  flag = 1;
    }
    if(flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>
char a[2],b[2];
int main()
{
	int i,c=0;
	scanf("%s",b);
	for(i=0;i<5;i++)
	{
		scanf("%s",a);
		if (a[0]==b[0]||a[1]==b[1])
		{
			c=1;
		}
	}
	if(c==1)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

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

int main()
{
    char a[2],b[11];int temp=0;
    gets(a);
    gets(b);
    for(int i=0;i<2;i++)
    {
    for(int j=0;j<11;j++)
        if(a[i]==a[j])
    {
    temp++;
    }
    }
    if(temp>0)
        printf("YES");
    else
        printf("NO");

    return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
char a[2];
char b[2];
gets(a);
int i,sum=0;
for(i=1;i<6;i++){
gets(b);
if(a[0]==b[0]||a[1]==b[1])
    {
    sum++;
}
else{continue;}
}
if(sum>0){
    printf("YES");
}
else{
    printf("NO");
}

}

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

int main()
{

	int i, j;
	char temp;
	char table[2] = { 0 };
	char hand[15] = { 0 };
	gets(table);
	gets(hand);

	for (j = 0; j < 2; j++)
	{
		temp = table[j];
		for (i = 0; i < 16; i++)
		{
			if (temp == hand[i])
			{
				printf("YES");
				exit(0);
			}

		}

	}
	printf("NO");
	exit(0);
	return 0;

}

#include<stdio.h>
#include<string.h>
main(){
char i[5],ii[5];
int a,sum=0;
getchar();
gets(i);

for(a=0;a<5;a++){

        gets(ii);
if(i[0]==ii[0]||i[1]==ii[1]){
    sum++;
}

}
if(sum>0){
    printf("\nYES");
}
else{
    printf("\nNO");
}

}

#include<stdio.h>
int main(){
	char t[3],h[3];
	int i,count = 0;
	scanf("%s",t);
	for(i=0;i<5;i++){
		scanf("%s",h);
		if(h[0]==t[0] || h[1]==t[1]){
			count = 1;
		}
	}
	 if(count = 1){
	     printf("YES");
	 }else {
	      printf("NO");
	 }

}

typedef struct {
    char rank,suit;
} card;
int main() {
    card c1, c2[5];
    scanf("%c%c",&c1.rank,&c1.suit);
    int i;
    for(i=0;i<5;i++) {
        scanf("%c%c ",&c2[i].rank,&c2[i].suit);
        if(c1.rank==c2[i].rank || c1.suit==c2[i].rank) {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main ()
{
		int x=0;
	char s[10];
	char a[10];
	int len1=strlen(s);
	int len2=strlen(a);
	scanf("%s",s);
	printf("as=%s\n",s);
	printf("aa=%c %c\n",s[0],s[1]);
	for(int i=0;i<5;i++)
	{
		scanf("%s",a);
		if(s[0]==a[0]||s[1]==a[1])
		{
			x=x+1;
    	}
    	else
    	{

		}
    }
	if(x==1)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

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

int main(void)
{

char str[3], str1[3], str2[3], str3[3], str4[3], str5[3];

scanf("%s",str);

scanf("%s %s %s %s %s",str1,str2,str3,str4,str5);

if(str[0]=str1[0]||str[0]==str2[0]||str[0]==str3[0]||str[0]==str4[0]||str[0]==str5[0]||str[1]==str1[1]||str[1]==str2[1]||str[1]==str3[1]||str[1]==str4[1]||str[1]==str5[1])

 printf("YES");

else

printf("NO");
	// your code goes here

return 0;
}

#include<stdio.h>
#include<strings.h>
#include<stdlib.h>
int main()
{
    int i,j;
    char s[3];
    char t[6][2];
    scanf("%s",s);
    for(i=0;i<5;i++)
    scanf("%s",t[i]);
    for(j=0;j<5;j++)
    {
      if(s[0]==t[i][0])
      {printf("YES");
      return 0;
      }
      if(s[1]==t[i][1])
      {
          printf("YES");
          return 0;
      }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()

{
    int i,l,flag=0;
    char s[12];
    char a,b;
    scanf("%c%c",&a,&b);
    scanf("%[^\n]s",&s);
    l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(a==s[i]||b==s[i])
        flag=1;
    }
    if(flag==1)
    printf("YES");
    else printf("NO");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char table[3],card[3],str[100];
    int n;
    scanf("%s", table);
    for(n=1;n<=5;n++)
    {
        scanf("%s", card);
        strcat(str, card);
    }
    for(n=1;str[n];n++)
    {
        if(table[0]==str[n] || table[1]==str[n])
        {
            printf("YES");
            return 0;
        }

    }
    printf("NO");
}

#include <stdio.h>

int
main ()
{
  int loop = 0, count1 = 0, count2 = 0;
  char array[100];

      scanf ("%c", array);

  printf("%c",array[0]);

    {
      if (array[1] == (array[4] || array[7] || array[10] || array[13]
	  || array[16]))
	{
	  printf ("YES");
	  return 0;
	}

      if (array[0] == (array[3] || array[6] || array[9] || array[12]
	  || array[15]))
	{
	  printf ("YES");
	  return 0;
	}

    }
  printf ("NO");
  return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[3],b[6][2];
    gets(a);
    for(int i=0;i<5;i++)
        {
            gets(b[i]);

        }
    for(int i=0;i<5;i++)
    {
        if(a[0]==b[i][0])
        {
            printf("Yes");
            return 0;
        }
        if(a[1]==b[i][1])
        {
            printf("Yes");
            return 0;
        }

    }
    printf("NO");

}

#include<stdio.h>
int main()
{
    char a,b,w;
    int count=0;
    scanf("%c %c %c",&a,&b,&w);
for(int i=0;i<5;i++)
{
char c,d,w;
scanf("%c %c %c",&c,&d,&w);
if(a==c || b==d)
{ printf("YES");
 break; }
else count++ ;
}
if(count==5)
printf("NO");
return 0;
}

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

int main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
 	#endif
 	int flag=0;
       char a[20];char b[10][10];
       scanf("%s",a);
       for(int i=0;i<5;i++)
       {
       	scanf("%s",b[i]);
       	if(a[0]==b[i][0]||a[1]==b[i][1])
       		flag=1;
       }
       if(flag==1)
       	printf("YES");
       else
       	printf("N0");
   }

#include<stdio.h>
main()
{
	char a[3], b[3];
	int i, c = 0;
	scanf("%s", a);
	for (i = 0; i < 5; i++)
	{
		scanf("%s", b);
		if (b[i] == a[0] || b[i] == a[1])
			c++;
	}
	if (c > 0)
		printf("YES\n");
	else
		printf("NO\n");
}

#include<stdio.h>
#include<string.h>
int main(){
int t=0;
char a[3],b[3];
gets(a);
for(int i=1;i<=5;i++){
gets(b);
if(b[0]==a[0]||b[1]==a[1])
    {
        t=1;
    }
}
(t==0?printf("NO"):printf("YES"));
return 0;
}

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

int main()
{

	int i, j;
	char temp;
	char table[2] = { 0 };
	char hand[15] = { 0 };
	gets(table);
	gets(hand);

	for (j = 0; j < 2; j++)
	{
		temp = table[j];
		for (i = 0; i < 16; i++)
		{
			if (temp == hand[i])
			{
				printf("YES");
				exit(0);

			}

		}
	}
	printf("NO");

	return 0;

}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,count=0;
    char str[10],str_[2];
    gets(str_);
    for(i=1;i<=5;i++)
    {
        gets(str);
        if(str[0]==str_[0] || str[0]==str_[1] || str[1]==str_[1])
        {
            count++;
        }
    }
    if(count>=1)
            printf("YES\n");
            else
                printf("NO\n");

    return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
	int c,k=0,t=0;
	char a,b;
	char ch[17];
	scanf("%c%c",&a,&b);
	puts(ch);
	for(int i=0;i<strlen(ch);i++)
	{
		if(a==ch[i] || b==ch[i])
		{
			k=1;

		}

	}
	if(k==1)
	printf("YES\n");
	else
	printf("NO\n");
	return 0;
}

#include<stdio.h>
int main()
{
int n=0;
char f,l,q;
scanf("%s",&f);
scanf("%s",&l);
char a,b,c;
while(n<5)
{
scanf("%s",&a);
scanf("%s",&b);
scanf("%s",&c);
n++;
}
if((f==b)||(l==c))
{
printf("YES");
}
else
{
printf("NO");
}
}

#include<stdio.h>

int main()
{
	char target[2],mine[2];
	int i,k=0;

	gets(target);
	scanf("%d",&i);

	for (i = 0; i < 5; ++i)
	{
		gets(mine);
		if(k==0 && (target[0]==mine[0] || target[1]==mine[1]))
		{
			k=1;
		}
	}

	if(k)
		printf("YES");
	else
		printf("NO");
}

#include<stdio.h>
int main(){
	char t[3],h[3];
	int i;
	scanf("%s",t);
	for(i=0;i<5;i++){
		scanf("%s",h);
		if(h[0]==t[0] || h[1]==t[1]){
			printf("YES");
			break;
		}
	 if(h == i){
	     printf("NO");
	 }
	}

}

#include<stdio.h>
char card(char a, char b)
{	int i;
	char k,l;
	for(i=0;i<10;i++)
	{ scanf("%c",&k);
	  scanf("%c",&l);
	}
	if(b==l||a==k||a==l||b==k)
	printf("YES");
	else
	printf("NO");
	return 0;
}
int main()
{	char a,b;
	scanf("%c",&a);
	scanf("%c",&b);
	card(a,b);
	return 0;
}

# include<stdio.h>

int main()
{
    int i;
    char s1[2];
    scanf("%s",&s1);

    char s2[2];
    scanf("%s",&s2);

    char s3[2];
    scanf("%s",&s3);

    char s4[2];
    scanf("%s",&s4);

    char s5[2];
    scanf("%s",&s5);

    char s6[2];
    scanf("%s",&s6);

    for(i=1; i<=2; i++)
    {
        if(s1[i]==s2[i])
        {
            printf("YES");

            return 0;
        }
        if(s1[i]==s3[i])
        {
            printf("YES");

            return 0;
        }
        if(s1[i]==s4[i])
        {
            printf("YES");

            return 0;
        }
        if(s1[i]==s5[i])
        {
            printf("YES");

            return 0;
        }
        if(s1[i]==s6[i])
        {
            printf("YES");

            return 0;
        }

    }  printf("NO");
    return 0;
}

#include<stdio.h>
main()
{
    int i,c;
    char a[2],b[2];
    scanf("%s",b);
    for(i=0;i<5;i++)
    {
        scanf("%s",a);
        if(b[0]==a[0]||b[1]==a[1])
        c=c+1;
    }
    if(c)printf("yes");
    else printf("no");
}

#include <stdio.h>
#include <stdlib.h>
/*
typedef struct Deck
{
	char club[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};
	char spades[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};
	char heart[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};
	char diamond[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};

}deck;
*/

typedef struct Card
{
	char face;
	char num;
}Card;

void write (Card a);

int main(void)
{
	int cont=0;
	Card table,hand[5];

	/*
	scanf("%c%c",&table.num,&table.face);
	*/
	scanf("%c%c%c%c%c%c%c%c%c%c",&hand[0].num,&hand[0].face,
								 &hand[1].num,&hand[1].face,
								 &hand[2].num,&hand[2].face,
								 &hand[3].num,&hand[3].face,
								 &hand[4].num,&hand[4].face);

	for(int i=0;i<5;i++)
		{
		write(hand[i]);
		}
	/*
	for(int i=0;i<5;i++)
	{
		if(hand[i].num==table.num ||hand[i].face==table.face)
		{
			printf("Yes");break;
			cont++;
		}
	}
	if(0==cont)
	{
		printf("No");
	}*/
}

void write (Card a)
{
	printf("%c%c",a.num,a.face);
}

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

int main()
{
    char a[2],b[2],c[2],d[2],e[2],f[2];int temp=0;
    gets(a);
    gets(b);
    gets(c);
    gets(d);
    gets(e);
    gets(f);
    for(int i=0;i<2;i++)
    {

        for(int j=0;j<2;j++)
        {
            if((a[i]==b[j])||(a[i]==c[j])||(a[i]==d[j])||(a[i]==e[j])||(a[i]==f[j]))
                temp++;
        }
    }
    if(temp>0)
    {

        printf("YES");

    }else{
    printf("NO");
    }

    return 0;
}

#include <stdio.h>
#include <stdbool.h>
int main (void)
{
	bool test = false ;
	char card[2] , hand_cards[20];
	int i,x ;
	scanf("%s",card);
	scanf("%s",hand_cards);
	for(i=0 ; i<2 ; i++)
	{
		for(x=0; x<10 ; x++)
		{
		if(card[i]== hand_cards[x])
		{
			test = true ;
			break ;
		}
		}	 //a7a
	}
	if (test)
		printf("yes");
	else
		printf("no");

}

#include<stdio.h>
main()
{
    int i,e=0;
    char a,b,c,d;
    scanf("%c%c",&a,&b);
    for(i=0;i<5;i++)
    {
        scanf("%c%c",&c,&d);
        if(a==c||a==d) e=e+1;
        if(b==c||b==d) e=e+1;
    }
    if(e!=0) {printf("yes");}
    else {printf("no");}

}

#include<stdio.h>
int main()
{
    int i,c;
    char a[2],b[2];
    scanf("%s",a);
    for(i=0;i<5;i++)
    {
    scanf("%s",b);
        if(a[0]==b[0]||a[1]==b[1])
           {
               c=1;
           }
    }
    if(c==1)
    printf("YES");
    else
    printf("NO");

    return(0);
}

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

int main()
{
    char table[2], hands[2];
    int s = 0;
    scanf("%s", table);

        for(int i = 0; i < 5; i++)
        {
           scanf("%c", hands);
           if(hands[s] == table[s] || hands[s+1] == table[s+1]) {printf("YES"); break; return 0;}
           else continue;
        }
    printf("NO ");
    return 0;
}

#include<stdio.h>

int main()
{
    char name[3], test[3], ans[] = "23456789TJQKA";
    int i, j, a, length, count = 0,b;

    length = strlen(ans);

    scanf("%s", name);

    for(i=1; i<=5; i++)
    {
        scanf("%s", test);

        if(test[0] == 'A' && name[0] == 'A')
        {

            count = 1;
        }
        else if((test[0] == name[0]) && (test[1] == name[1]))
        {

            count = 1;
        }
        else if(test[1] == name[1])
        {
            count = 1;

        }
    }

    if(count == 1)
    {

        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }

    return 0;
}

#include<stdio.h>
int main(void)
{
    char a[1][3],b[5][3];
    int i,j;
    for(i=0;i<1;i++)
    {
        for(j=0;j<3;j++)
        {
            scanf("%c",&a[i][j]);
        }
    }
    fflush(stdin);
    int flag=0;
        for(i=0;i<5;i++)
        {
            for(j=0;j<3;j++)
            {
                //fflush(stdin);
                scanf("%c",&b[i][j]);
                if(a[1][1]==b[i][1]) flag++;
                if(a[1][2]==b[i][2]) flag++;
            }
            getchar();
        }
    if(flag==0) printf("NO\n");
    else printf("YES\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
main(){
char i[5],ii[5];
int a,sum=0;
getchar();
gets(i);
for(a=0;a<5;a++){
        gets(ii);
if(i[0]==ii[0]||i[1]==i[1]){
    sum++;
}
}
if(sum>0){
    printf("YES");
}
else{
    printf("NO");
}

}

#include <stdio.h>

int
main ()
{
  int loop = 0, count1 = 0, count2 = 0;
  char array[100];

    fgets(array,100,stdin);

    {
      if (array[1] == array[4] ||array[1] == array[7] ||array[1] == array[10] ||array[1] == array[13]
	  ||array[1] == array[16])
	{
	  printf ("YES");
	  return 0;
	}

      if (array[0] == array[3] ||array[0] ==  array[6] ||array[0] ==  array[9] ||array[0] ==  array[12]
	  ||array[0] ==  array[15])
	{
	  printf ("YES");
	  return 0;
	}

    }
  printf ("NO");
  return 0;
}

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

int main()
{
    char onTable[3];
    char inHand[15];

    scanf("%s\n", onTable);
    fgets(inHand, 15, stdin);

    for (short i = 0; i < 15; i += 2) {
        if (onTable[0] == inHand[i] || onTable[1] == inHand[i+1]) {
            puts("YES");
            exit(0);
        }
    }
    puts("NO");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
struct liste{
    char name[30];
    struct liste *next;
};
typedef struct liste *liste ;
liste creation(int n){
    liste head,tmp,pt;
    head=malloc(sizeof(struct liste));
    scanf("%s",head->name);
    head->next=NULL;
    pt=head;
     for(int i=1;i<n;i++){
        tmp=malloc(sizeof(struct liste));
        scanf("%s",tmp->name);
        tmp->next=NULL;
        pt->next=tmp;
        pt=tmp;
     }
      return head;

}
int traitement(char card[],liste L){
    int i=0,ok=0,j=0;
    while(L){
    j=0;
        do{
            i=0;
        while(i<2){
            if(card[j]==L->name[i]){
                printf("yes");

                return 0;
          }
            i++;
                  }
            j++;
        }while(j<2);

       L=L->next;
}
    printf("non");
}
 int main(){
char card[2];
liste L;
 scanf("%s",card);
 if(*card='\0')return 0;
 L=creation(5);
   traitement(card,L);

 }

#include<stdio.h>
#include<string.h>
main(){
char a[2];
char b[2];
int i,sum=0;
getchar();
scanf("%s",a);
for(i=1;i<6;i++){
scanf("%s",b);
if(a[1]==b[1]||a[0]==b[0])
    {
    sum++;
}

}
if(sum>0){
    printf("YES");
}
else{
    printf("NO");
}

}

#include<stdio.h>
int main()
{
    int i,c;
    char a[2],b[2];
    for(i=0;i<2;i++)
    scanf("%s",a);
    for(i=0;i<20;i++)
    scanf("%s",b);
    for(i=0;i<20;i++)
    {
        if(a[0]==b[i]||a[1]==b[i])
           {
               c=1;
               break;
           }
        else
            c=0;
    }
    if(c==1)
    printf("YES");
    else
    printf("NO");

    return(0);
}

typedef struct {
    char rank,suit;
} card;
int main() {
    card c1, c2[5];
    scanf("%c%c",&c1.rank,&c1.suit);
    int i;
    for(i=0;i<5;i++) {
        scanf("%*c%c%c",&c2[i].rank,&c2[i].suit);
        if(c1.rank==c2[i].rank || c1.suit==c2[i].rank) {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

#include <stdio.h>

int main(void) {
    char str[3], str1[3], str2[3], str3[3], str4[3], str5[3];
    scanf("%s",str);
    scanf("%s %s %s %s %s",str1,str2,str3,str4,str5);
    if((str[1]==(str1[1]||str2[1]||str3[1]||str4[1]||str5[1]))||(str[2]==(str1[2]||str2[2]||str3[2]||str4[2]||str5[2])))
    printf("YES");
    else
    printf("NO");
	// your code goes here
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
/*
typedef struct Deck
{
	char club[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};
	char spades[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};
	char heart[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};
	char diamond[13]= {2,3,4,5,6,7,8,9,'T','J','Q','K','A'};

}deck;
*/

typedef struct Card
{
	char face;
	char num;
}Card;
/*
void write (Card a);
*/
int main(void)
{
	int cont=0;
	Card table,hand[5];
	scanf("%c%c",&table.num,&table.face);

	scanf("%c%c%c%c%c%c%c%c%c%c",&hand[0].num,&hand[0].face,
								 &hand[1].num,&hand[1].face,
								 &hand[2].num,&hand[2].face,
								 &hand[3].num,&hand[3].face,
								 &hand[4].num,&hand[4].face);
	/*
	for(int i=0;i<5;i++)
		{
		write(hand[i]);
		}
	*/
	for(int i=0;i<5;i++)
	{
		if(hand[i].num==table.num ||hand[i].face==table.face)
		{
			printf("Yes");break;
			cont++;
		}
	}
	if(0==cont)
	{
		printf("No");
	}
}
/*
void write (Card a)
{
	printf("%c%c",a.num,a.face);
}
*/

#include<stdio.h>
#include<string.h>
int main()
{

    int r=0,s=0;
    char card[2];
    char cards[15];
    gets(card);
    gets(cards);
    for(int i=0;i<strlen(cards);i+=3)
    {
        if(card[0]==cards[i])
        r++;
    }

    for(int i=1;i<strlen(cards);i+=3)
    {
        if(card[1]==cards[i])
        s++;
    }
    if((r==1 && s<2) || (s==1 && r<2))
    printf("YES\n");
    else
    printf("NO\n");
    return 0;
}

#include<stdio.h>
int main()
{
char str[2],str1[5];
int count=0,i,j,p;
scanf("%s",str);
for(i=0;i<4;i++)
{
    scanf("%s",str1);
    p=0;
    for(j=0;j<2;j++,p++)
    {
    if(str[p]==str1[j])
    count=count+1;
     break;
    }
    }
    if(count>0)
    printf("Yes");
    else
    printf("No");
return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[3],b[6][2];
    gets(a);
    for(int i=0;i<5;i++)
        {
            gets(b[i]);

        }
    for(int i=0;i<5;i++)
    {
        if(a[0]==b[i][0])
        {
            printf("Yes");
            return 0;
        }
        if(a[1]==b[i][1])
        {
            printf("Yes");
            return 0;
        }

    }
    printf("NO");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct liste{
    char name[30];
    struct liste *next;
};
typedef struct liste *liste ;
liste creation(int n){
    liste head,tmp,pt;
    head=malloc(sizeof(struct liste));
    scanf("%s",head->name);
    head->next=NULL;
    pt=head;
     for(int i=1;i<n;i++){
        tmp=malloc(sizeof(struct liste));
        scanf("%s",tmp->name);
        tmp->next=NULL;
        pt->next=tmp;
        pt=tmp;
     }
      return head;

}
int traitement(char card[],liste L){
    int i=0,ok=0,j=0;
    while(L){
    j=0;
        do{
            i=0;
        while(i<2){
            if(card[j]==L->name[i]&&(card[j]>64&&card[j]<91)){
                printf("yes");

                return 0;
          }
            i++;
                  }
            j++;
        }while(j<2);

       L=L->next;
}
    printf("non");
}
 int main(){
char card[2];
liste L;
 scanf("%s",card);
 if(strlen(card)>2 )return 0;
 L=creation(5);
   traitement(card,L);

 }

#include <stdio.h>

int main() {
	char T[3];
	printf("please Enter");
	scanf("%s", T);
	char hand[5][3];
	int i;
	int flag=1;
	for(i=0;i<5;i++){
		scanf("%s", hand[i]);
	}
	for(i=0;i<5;i++){
		if((hand[i][0]==T[0] )||(hand[i][1]==T[1] )){
			printf("YES\n");
			flag=0;
			break;

		}

	}
	if(flag){
		printf("NO\n");
	}
}


#include <stdio.h>

const unsigned int mod = 1000000007;
unsigned int DP[5001][5001];
char a[5001],b[5001];

int main()
{
    gets(a);gets(b);
    int len1 = strlen(a),len2 = strlen(b),i,j;
    for(i=0;i<len1;++i){
        for(j=0;j<len2;++j){
            DP[i+1][j+1] = (DP[i+1][j] + ((a[i]==b[j])? (DP[i][j]+1) : 0))%mod;
        }
    }

    unsigned int ans = 0;
    for(i=1;i<=len1;++i){
        ans+=DP[i][len2];
        ans %=mod;
    }
    printf("%d",ans);

    //system("pause");
    return 0;
}

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

typedef long long ll;

#define err(...) fprintf(stderr, __VA_ARGS__)

#define N 5010
#define MOD 1000000007

void norm(ll *a) {
  if (*a >= MOD) *a -= MOD;
  if (*a < 0) *a += MOD;
}

int main() {
  static char s[N], t[N];
  scanf("%s %s", s, t);
  int n = strlen(s), m = strlen(t);

  ll ans = 0;
  static ll dp[N][N];
  for (int i = 0; i <= (n > m ? n : m); ++i) {
    dp[0][i] = 1;
    dp[i][0] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      dp[i][j] = dp[i][j - 1];
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] += dp[i - 1][j - 1];
        norm(&dp[i][j]);
      }
      if (j == m) {
        ans += dp[i][j];
        norm(&ans);
      }
    }
  }
  ans = (ans + MOD - n) % MOD;

  printf("%lld", ans);
  return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define MAX 5010
#define MOD 1000000007
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

char S[MAX], T[MAX];
short next[MAX][MAX];
bool visited[MAX][MAX];
int n, m, dp[MAX][MAX];

int F(int i, int j){
    if (i >= n || j >= m) return 0;
    if (visited[i][j]) return dp[i][j];

    unsigned int res = 0;
    if (next[i][j] != -1){
        res = res + F(i + 1, next[i][j] + 1) + 1;
        if (res >= MOD) res -= MOD;
        res = res + F(i, next[i][j] + 1);
        if (res >= MOD) res -= MOD;
    }

    visited[i][j] = true;
    return (dp[i][j] = res);
}

int main(){
    int i, j, k;

    while (scanf("%s %s", S, T) != EOF){
        clr(visited);
        n = strlen(S), m = strlen(T);
        for (i = 0; i < n; i++){
            for (j = m - 1; j >= 0; j--){
                next[i][j] = -1;
                if (S[i] == T[j]) next[i][j] = j;
                else if ((j + 1) != m) next[i][j] = next[i][j + 1];
            }
        }

        long long res = 0;
        for (i = 0; i < n; i++){
            for (j = 0; j < m; j++){
                if (S[i] == T[j]){
                    res = res + F(i + 1, j + 1) + 1;
                }
            }
        }
        printf("%lld\n", res % MOD);
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
#define MAXN 5000
#define MAXL (MAXN+1)
#define MOD 1000000007

char s[MAXL];
char t[MAXL];

int dp[MAXN][MAXN];

int main()
{
	while ( scanf("%s %s", s, t) == 2)
	{
		//printf("%s\n%s\n", s, t);
		int ls = strlen( s);
		int lt = strlen( t);

		int i, j;
		int ans = 0;
		for ( i = 0; i < ls; i++)
		{
			for ( j = 0; j < lt; j++)
			{
				dp[i][j] = s[i] == t[j];
				if ( dp[i][j] && i && j)
				{
					dp[i][j] += dp[i-1][j-1];
				}

				dp[i][j] %= MOD;
				ans += dp[i][j];
				ans %= MOD;

				dp[i][j] += j ? dp[i][j-1] : 0;
				dp[i][j] %= MOD;
			}
		}
		/*
		for ( i = 0; i < ls; i++)
		{
			for ( j = 0; j < lt; j++)
			{
				printf("%d ", dp[i][j]);
			}
			printf("\n");
		}
		*/
		printf("%d\n", ans);
	}
	return 0;
}

#include <stdio.h>
#include <string.h>
#define MAXN 5000
#define MAXL (MAXN+1)
#define MOD 1000000007

char s[MAXL];
char t[MAXL];

int oct[MAXN][26];
int dp[MAXN][MAXN];

int main()
{
	while ( scanf("%s %s", s, t) == 2)
	{
		//printf("%s\n%s\n", s, t);
		int ls = strlen( s);
		int lt = strlen( t);

		int i, j;
		int ans = 0;
		memset( oct[0], 0, sizeof( oct[0]));
		++oct[0][t[0]-'a'];
		for ( i = 1; i < lt; i++)
		{
			for ( j = 0; j < 26; j++)
			{
				oct[i][j] = oct[i-1][j];
			}
			++oct[i][t[i]-'a'];
		}

		for ( i = 0; i < ls; i++)
		{
			for ( j = 0; j < lt; j++)
			{
				dp[i][j] = s[i] == t[j];
				if ( dp[i][j] && i && j)
				{
					dp[i][j] += dp[i-1][j-1];
				}

				ans += dp[i][j];
				if ( ans >= MOD)
				{
					ans -= MOD;
				}
				dp[i][j] += j ? dp[i][j-1] : 0;
			}
		}
		/*
		for ( i = 0; i < ls; i++)
		{
			for ( j = 0; j < lt; j++)
			{
				printf("%d ", dp[i][j]);
			}
			printf("\n");
		}
		*/
		printf("%d\n", ans);
	}
	return 0;
}

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

typedef long long ll;

#define err(...) fprintf(stderr, __VA_ARGS__)

#define N 5010
#define MOD 1000000007

void norm(ll *a) {
  if (*a >= MOD) *a -= MOD;
  if (*a < 0) *a += MOD;
}

int main() {
  static char s[N], t[N];
  scanf("%s %s", s, t);
  int n = strlen(s), m = strlen(t);

  ll ans = 0;
  static ll dp[N][N];
  for (int i = 0; i <= n; ++i) {
    dp[0][i] = 1;
    dp[i][0] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      dp[i][j] = dp[i][j - 1];
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] += dp[i - 1][j - 1];
        norm(&dp[i][j]);
      }
      if (j == m) {
        ans += dp[i][j];
        norm(&ans);
      }
    }
  }
  ans = (ans + MOD - n) % MOD;

  printf("%lld", ans);
  return 0;
}