stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int a[3][3];

	for(int i=0;i<3;i++)

	{

		for(int j=0;j<3;j++)

		{

			cin>>a[i][j];

		}

	}

	int t,b;

	cin>>t;

	while(t--)

	{

		cin>>b;

		for(int i=0;i<3;i++)

		{

			for(int j=0;j<3;j++)

			{

				if(a[i][j]==b)

				  a[i][j]=0;

			}

		}

	}

	bool flag1=0,flag2=0,flag3=0;

	for(int i=0;i<3;i++)

	{

		for(int j=0;j<3;j++)

		{

			if(a[i][j])

			  break;

			if(j==2&&a[i][j]==0)

			  flag1=1;

		}

	}

	for(int j=0;j<3;j++)

	{

		for(int i=0;i<3;i++)

		{

			if(a[i][j])

			  break;

			if(i==2&&a[i][j]==0)

			  flag2=1;

		}

	}

	for(int i=0;i<3;i++)

	{

		if(a[i][i])

		  break;

		if(i==2&&a[i][i]==0)

		  flag3=1;

	}

	for(int i=0;i<3;i++)

	{

		if(a[i][2-i])

		  break;

		if(i==2&&a[i][2-i]==0)

		  flag3=1;

	}

	if(flag1||flag2||flag3)

	  cout<<"Yes"<<endl;

	else

	  cout<<"No"<<endl;

 } 

// Faster C++ solution for the same problem (measured speedup: 5.266807862277568x):
#include<stdio.h>

int main(){

	int arr[3][3];

	int tc;

	int add;

	int check[3][3]= {0};

	int count;

	int i,j;

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

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

			scanf("%d", &arr[i][j]);

		}

	}

	scanf("%d",&tc);

	int k;

	

	for(k=0;k<tc;k++){

		scanf("%d",&add);

		int j;

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

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

				if(arr[i][j]== add){

					check[i][j] = 1;

				}

			}

		}

	}

	if(check[0][0]+ check [1][1]+ check[2][2]== 3 || check [0][2]+check [1][1]+ check[2][0]==3){

		printf("Yes\n");

		return 0;

	}

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

		if(check[i][0]+check[i][1]+check[i][2]==3 || check [0][i]+check[1][i]+check[2][i]==3){

			printf("Yes\n");

			return 0;

		}

	}

	printf("No\n");

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<cstring>

#include<iomanip>

#include<string>

#include<set>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<utility>

#define PI acos(-1.0)

using namespace std;

int a[3][3];

int main() {

	int n;

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

		for(int j = 0; j < 3; j++) {

			scanf("%d",&a[i][j]);

		}

	}

	cin >> n;

	int b;

	while(n--) {

		cin >> b;

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

			for(int j = 0; j < 3; j++) {

				if(a[i][j] == b) {

					a[i][j] = 0;

					break;

				}

			}

		}

	}

	int flag = 0;

	int ans = 0;

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

		ans = 0;

		for(int j = 0; j < 3; j++) {

			if(a[i][j] == 0) ans++;

			else break;

		}

		if(ans == 3) {

			flag = 1;

			break;

		}

	}

	if(flag) cout << "Yes" << endl;

	else {

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

			ans = 0;

			for(int j = 0; j < 3; j++) {

				if(a[j][i] == 0) ans++;

				else break;

			}

			if(ans == 3) {

				flag = 1;

				break;

			}

		}

		if(flag) cout << "Yes" << endl;

		else{

			if((a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)||(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)){

				flag = 1;

			}

			if(flag) cout << "Yes" << endl;

			else cout << "No" << endl;

		}

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.232316967113702x):
#include <stdio.h>



int main(){

    int matrix[3][3];

    char x;

    

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

        for(int j=0; j<3; j++){

            scanf("%d", &matrix[i][j]);

        }

    }

    

    int n;

    scanf("%d", &n);

    

    int input[n];

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

        scanf("%d", &input[k]);

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

            for(int j=0; j<3; j++){

                if(input[k] == matrix[i][j]){

                    matrix[i][j] = x;

                }

            }

        }

    }

    

    int ctr[8] = {0};

    int last=2;

    

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

        if(matrix[i][0]==x){

            ++ctr[0];

        }

        if(matrix[i][2]==x){

            ++ctr[1];

        }

        if(matrix[0][i]==x){

            ++ctr[2];

        }

        if(matrix[2][i]==x){

            ++ctr[3];

        }

        if(matrix[i][i]==x){

            ++ctr[4];

        } 

        if(matrix[i][last--]==x){

            ++ctr[5];

        }

        if(matrix[1][i]==x){

            ++ctr[6];

        }

        if(matrix[i][1]==x){

            ++ctr[7];

        }

    }

    

    int flag = 0;

    

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

        if(ctr[i] == 3){

            flag = 1;

        }

    }

    printf("%s\n", (flag == 1) ? "Yes" : "No");



    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int a[15],b,i,p[15]={0};

	for(i=1;i<=9;i++)

		cin>>a[i];

	int n;

	cin>>n;

	for(int j=0;j<n;j++)

	{

		cin>>b;

		for(i=1;i<=9;i++)

			if(b==a[i])

				p[i]=1;

	}

	if(p[5]==1)

	{

		if(p[2]==1&&p[8]==1) cout<<"Yes"<<endl;

		else if(p[1]==1&&p[9]==1) cout<<"Yes"<<endl;

		else if(p[3]==1&&p[7]==1) cout<<"Yes"<<endl;

		else if(p[4]==1&&p[6]==1) cout<<"Yes"<<endl;

		else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	}

	else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

			else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	else cout<<"No"<<endl;

	 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2070215821896415x):
#include <stdio.h>



int main(){

    int matrix[3][3];

    char x;

    

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

        for(int j=0; j<3; j++){

            scanf("%d", &matrix[i][j]);

        }

    }

    

    int n;

    scanf("%d", &n);

    

    int input[n];

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

        scanf("%d", &input[k]);

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

            for(int j=0; j<3; j++){

                if(input[k] == matrix[i][j]){

                    matrix[i][j] = x;

                }

            }

        }

    }

    

    int ctr[8] = {0};

    int last=2;

    

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

        if(matrix[i][0]==x){

            ++ctr[0];

        }

        if(matrix[i][2]==x){

            ++ctr[1];

        }

        if(matrix[0][i]==x){

            ++ctr[2];

        }

        if(matrix[2][i]==x){

            ++ctr[3];

        }

        if(matrix[i][i]==x){

            ++ctr[4];

        } 

        if(matrix[i][last--]==x){

            ++ctr[5];

        }

        if(matrix[1][i]==x){

            ++ctr[6];

        }

        if(matrix[i][1]==x){

            ++ctr[7];

        }

    }

    

    int flag = 0;

    

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

        if(ctr[i] == 3){

            flag = 1;

        }

    }

    printf("%s\n", (flag == 1) ? "Yes" : "No");



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<cstring>

#include<iomanip>

#include<string>

#include<set>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<utility>

#define PI acos(-1.0)

using namespace std;

int a[3][3];

int main() {

	int n;

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

		for(int j = 0; j < 3; j++) {

			scanf("%d",&a[i][j]);

		}

	}

	cin >> n;

	int b;

	while(n--) {

		cin >> b;

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

			for(int j = 0; j < 3; j++) {

				if(a[i][j] == b) {

					a[i][j] = 0;

					break;

				}

			}

		}

	}

	int flag = 0;

	int ans = 0;

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

		ans = 0;

		for(int j = 0; j < 3; j++) {

			if(a[i][j] == 0) ans++;

			else break;

		}

		if(ans == 3) {

			flag = 1;

			break;

		}

	}

	if(flag) cout << "Yes" << endl;

	else {

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

			ans = 0;

			for(int j = 0; j < 3; j++) {

				if(a[j][i] == 0) ans++;

				else break;

			}

			if(ans == 3) {

				flag = 1;

				break;

			}

		}

		if(flag) cout << "Yes" << endl;

		else{

			if((a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)||(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)){

				flag = 1;

			}

			if(flag) cout << "Yes" << endl;

			else cout << "No" << endl;

		}

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.290897663517478x):
#include <stdio.h>

int main(){

    int array[3][3];

    int n; 

    int add;

    int check[3][3]={0};

    int count;

    for(int i = 0; i < 3; i++)

	{ 

        for(int j = 0; j < 3; j++)

		{ 

            scanf("%d", &array[i][j]);

        } 

    }

    scanf("%d",&n);

    for(int k = 0; k < n; k++)

	{

        scanf("%d",&add);

        for(int i = 0; i < 3; i++)

		{

            for(int j = 0; j < 3; j++)

			{

                if(array[i][j] == add)

                {

                    check[i][j] = 1;

                }

            }

        }

    }

    if(check[0][0] + check[1][1] + check[2][2] == 3 || check[0][2] + check[1][1] + check[2][0] == 3)

	{

        printf("Yes\n");

        return 0;

    }

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

        if(check[i][0] + check[i][1] + check[i][2] == 3 || check[0][i] + check[1][i] + check[2][i] == 3)

		{

            printf("Yes\n");

            return 0;

        }

    }

    printf("No\n");

    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int a[15],b,i,p[15]={0};

	for(i=1;i<=9;i++)

		cin>>a[i];

	int n;

	cin>>n;

	for(int j=0;j<n;j++)

	{

		cin>>b;

		for(i=1;i<=9;i++)

			if(b==a[i])

				p[i]=1;

	}

	if(p[5]==1)

	{

		if(p[2]==1&&p[8]==1) cout<<"Yes"<<endl;

		else if(p[1]==1&&p[9]==1) cout<<"Yes"<<endl;

		else if(p[3]==1&&p[7]==1) cout<<"Yes"<<endl;

		else if(p[4]==1&&p[6]==1) cout<<"Yes"<<endl;

		else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	}

	else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

			else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	else cout<<"No"<<endl;

	 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.26531907303191x):
#include <stdio.h>

int main(){

    int array[3][3];

    int n; 

    int add;

    int check[3][3]={0};

    int count;

    for(int i = 0; i < 3; i++)

	{ 

        for(int j = 0; j < 3; j++)

		{ 

            scanf("%d", &array[i][j]);

        } 

    }

    scanf("%d",&n);

    for(int k = 0; k < n; k++)

	{

        scanf("%d",&add);

        for(int i = 0; i < 3; i++)

		{

            for(int j = 0; j < 3; j++)

			{

                if(array[i][j] == add)

                {

                    check[i][j] = 1;

                }

            }

        }

    }

    if(check[0][0] + check[1][1] + check[2][2] == 3 || check[0][2] + check[1][1] + check[2][0] == 3)

	{

        printf("Yes\n");

        return 0;

    }

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

        if(check[i][0] + check[i][1] + check[i][2] == 3 || check[0][i] + check[1][i] + check[2][i] == 3)

		{

            printf("Yes\n");

            return 0;

        }

    }

    printf("No\n");

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<cstring>

#include<iomanip>

#include<string>

#include<set>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<utility>

#define PI acos(-1.0)

using namespace std;

int a[3][3];

int main() {

	int n;

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

		for(int j = 0; j < 3; j++) {

			scanf("%d",&a[i][j]);

		}

	}

	cin >> n;

	int b;

	while(n--) {

		cin >> b;

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

			for(int j = 0; j < 3; j++) {

				if(a[i][j] == b) {

					a[i][j] = 0;

					break;

				}

			}

		}

	}

	int flag = 0;

	int ans = 0;

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

		ans = 0;

		for(int j = 0; j < 3; j++) {

			if(a[i][j] == 0) ans++;

			else break;

		}

		if(ans == 3) {

			flag = 1;

			break;

		}

	}

	if(flag) cout << "Yes" << endl;

	else {

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

			ans = 0;

			for(int j = 0; j < 3; j++) {

				if(a[j][i] == 0) ans++;

				else break;

			}

			if(ans == 3) {

				flag = 1;

				break;

			}

		}

		if(flag) cout << "Yes" << endl;

		else{

			if((a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)||(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)){

				flag = 1;

			}

			if(flag) cout << "Yes" << endl;

			else cout << "No" << endl;

		}

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.287476092212422x):
#include <stdio.h>



int main() {

  int a[3][3], n;

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

    for(int j = 0; j < 3; j++) {

      scanf("%d", &a[i][j]);

    }

  }

  scanf("%d", &n);



  int b[n];

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

      scanf("%d", &b[i]);

    

    for(int j = 0; j < 3; j++) {

        for(int k = 0; k < 3; k++) {

            if(b[i] == a[j][k]) {

              a[j][k] = 0;

            }

        }

    }



  }



  if( a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0 )   printf("Yes");



  else if( a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0 )  printf("Yes");



  else if( a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0 )  printf("Yes");



  else if( a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0 )  printf("Yes");



  else if( a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0 ) printf("Yes");



  else if( a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0 ) printf("Yes");



  else if( a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0 ) printf("Yes");



  else if( a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0 ) printf("Yes");



  else  printf("No");



  return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int a[15],b,i,p[15]={0};

	for(i=1;i<=9;i++)

		cin>>a[i];

	int n;

	cin>>n;

	for(int j=0;j<n;j++)

	{

		cin>>b;

		for(i=1;i<=9;i++)

			if(b==a[i])

				p[i]=1;

	}

	if(p[5]==1)

	{

		if(p[2]==1&&p[8]==1) cout<<"Yes"<<endl;

		else if(p[1]==1&&p[9]==1) cout<<"Yes"<<endl;

		else if(p[3]==1&&p[7]==1) cout<<"Yes"<<endl;

		else if(p[4]==1&&p[6]==1) cout<<"Yes"<<endl;

		else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	}

	else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

			else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	else cout<<"No"<<endl;

	 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.261914043148896x):
#include <stdio.h>



int main() {

  int a[3][3], n;

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

    for(int j = 0; j < 3; j++) {

      scanf("%d", &a[i][j]);

    }

  }

  scanf("%d", &n);



  int b[n];

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

      scanf("%d", &b[i]);

    

    for(int j = 0; j < 3; j++) {

        for(int k = 0; k < 3; k++) {

            if(b[i] == a[j][k]) {

              a[j][k] = 0;

            }

        }

    }



  }



  if( a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0 )   printf("Yes");



  else if( a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0 )  printf("Yes");



  else if( a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0 )  printf("Yes");



  else if( a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0 )  printf("Yes");



  else if( a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0 ) printf("Yes");



  else if( a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0 ) printf("Yes");



  else if( a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0 ) printf("Yes");



  else if( a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0 ) printf("Yes");



  else  printf("No");



  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<cstring>

#include<iomanip>

#include<string>

#include<set>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<utility>

#define PI acos(-1.0)

using namespace std;

int a[3][3];

int main() {

	int n;

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

		for(int j = 0; j < 3; j++) {

			scanf("%d",&a[i][j]);

		}

	}

	cin >> n;

	int b;

	while(n--) {

		cin >> b;

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

			for(int j = 0; j < 3; j++) {

				if(a[i][j] == b) {

					a[i][j] = 0;

					break;

				}

			}

		}

	}

	int flag = 0;

	int ans = 0;

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

		ans = 0;

		for(int j = 0; j < 3; j++) {

			if(a[i][j] == 0) ans++;

			else break;

		}

		if(ans == 3) {

			flag = 1;

			break;

		}

	}

	if(flag) cout << "Yes" << endl;

	else {

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

			ans = 0;

			for(int j = 0; j < 3; j++) {

				if(a[j][i] == 0) ans++;

				else break;

			}

			if(ans == 3) {

				flag = 1;

				break;

			}

		}

		if(flag) cout << "Yes" << endl;

		else{

			if((a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)||(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)){

				flag = 1;

			}

			if(flag) cout << "Yes" << endl;

			else cout << "No" << endl;

		}

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3002404677962645x):
#include<stdio.h>



int main(){

	int arr[3][3], flag[3][3] = {0};

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

		for(int j = 0; j < 3; j++){

			scanf("%d", &arr[i][j]);

		}

	}

	int n;

	scanf("%d", &n);

	int brr[n];

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

		scanf("%d", &brr[i]);

		for(int j = 0; j < 3; j++){

			for(int k = 0; k < 3; k++){

				if(arr[j][k] == brr[i]){

					flag[j][k] = 1;

				}

			}

		}

	}

	int check = 0;

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

		if(flag[i][0] && flag[i][1] && flag[i][2]){

			check = 1;

		}

	}

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

		if(flag[0][i] && flag[1][i] && flag[2][i]){

			check = 1;

		}

	}

	if(flag[0][0] && flag[1][1] && flag[2][2]){

		check = 1;

	}

	if(flag[0][2] && flag[1][1] && flag[2][0]){

		check = 1;

	}

	(check) ? puts("Yes") : puts("No");

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int a[15],b,i,p[15]={0};

	for(i=1;i<=9;i++)

		cin>>a[i];

	int n;

	cin>>n;

	for(int j=0;j<n;j++)

	{

		cin>>b;

		for(i=1;i<=9;i++)

			if(b==a[i])

				p[i]=1;

	}

	if(p[5]==1)

	{

		if(p[2]==1&&p[8]==1) cout<<"Yes"<<endl;

		else if(p[1]==1&&p[9]==1) cout<<"Yes"<<endl;

		else if(p[3]==1&&p[7]==1) cout<<"Yes"<<endl;

		else if(p[4]==1&&p[6]==1) cout<<"Yes"<<endl;

		else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	}

	else if(p[1]==1)

		{

			if(p[2]==1&&p[3]==1) cout<<"Yes"<<endl;

			else if(p[4]==1&&p[7]==1) cout<<"Yes"<<endl;

			else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

		}

		else if(p[9]==1)

		{

			if(p[3]==1&&p[6]==1) cout<<"Yes"<<endl;

			else if(p[7]==1&&p[8]==1) cout<<"Yes"<<endl;

			else cout<<"No"<<endl;

		}

	else cout<<"No"<<endl;

	 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.274616709972405x):
#include<stdio.h>



int main(){

	int arr[3][3], flag[3][3] = {0};

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

		for(int j = 0; j < 3; j++){

			scanf("%d", &arr[i][j]);

		}

	}

	int n;

	scanf("%d", &n);

	int brr[n];

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

		scanf("%d", &brr[i]);

		for(int j = 0; j < 3; j++){

			for(int k = 0; k < 3; k++){

				if(arr[j][k] == brr[i]){

					flag[j][k] = 1;

				}

			}

		}

	}

	int check = 0;

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

		if(flag[i][0] && flag[i][1] && flag[i][2]){

			check = 1;

		}

	}

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

		if(flag[0][i] && flag[1][i] && flag[2][i]){

			check = 1;

		}

	}

	if(flag[0][0] && flag[1][1] && flag[2][2]){

		check = 1;

	}

	if(flag[0][2] && flag[1][1] && flag[2][0]){

		check = 1;

	}

	(check) ? puts("Yes") : puts("No");

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;

#define LL long long

#define MAX_SIZE 1010

int n, m;

LL r, a;

LL x[MAX_SIZE], y[MAX_SIZE], z[MAX_SIZE], t[MAX_SIZE];



int main()

{

	cin >> n >> m;

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

		cin >> x[i] >> y[i] >> z[i];



	int P[8][3] = { { 1,1,1 },{ 1,1,-1 },{ 1,-1,1 },{ 1,-1,-1 },{ -1,1,1 },{ -1,1,-1 },{ -1,-1,1 },{ -1,-1,-1 } };

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

		for (int j = 0; j < n; ++j)

			t[j] = x[j] * P[i][0] + y[j] * P[i][1] + z[j] * P[i][2];

		sort(t, t + n);

		a = 0;

		for (int k = n - m; k < n; ++k)

			a += t[k];

		if (r < a)

			r = a;

	}

	cout << r << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.146273595436935x):
#include <cstdio>

#include <algorithm>

using namespace std;

#define LL long long

#define MAX_SIZE 1010

int n, m;

LL r, a;

LL x[MAX_SIZE], y[MAX_SIZE], z[MAX_SIZE], t[MAX_SIZE];



int main()

{

	scanf("%d %d", &n, &m);

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

		scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);



	int P[8][3] = { { 1,1,1 },{ 1,1,-1 },{ 1,-1,1 },{ 1,-1,-1 },{ -1,1,1 },{ -1,1,-1 },{ -1,-1,1 },{ -1,-1,-1 } };

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

		for (int j = 0; j < n; ++j)

			t[j] = x[j] * P[i][0] + y[j] * P[i][1] + z[j] * P[i][2];

		sort(t, t + n);

		a = 0;

		for (int k = n - m; k < n; ++k)

			a += t[k];

		if (r < a)

			r = a;

	}

	printf("%lld\n", r);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;

#define LL long long

#define MAX_SIZE 1010

int n, m;

LL r, a;

LL x[MAX_SIZE], y[MAX_SIZE], z[MAX_SIZE], t[MAX_SIZE];



int main()

{

	ios::sync_with_stdio(false);

	cin >> n >> m;

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

		cin >> x[i] >> y[i] >> z[i];



	int P[8][3] = { { 1,1,1 },{ 1,1,-1 },{ 1,-1,1 },{ 1,-1,-1 },{ -1,1,1 },{ -1,1,-1 },{ -1,-1,1 },{ -1,-1,-1 } };

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

		for (int j = 0; j < n; ++j)

			t[j] = x[j] * P[i][0] + y[j] * P[i][1] + z[j] * P[i][2];

		sort(t, t + n);

		a = 0;

		for (int k = n - m; k < n; ++k)

			a += t[k];

		if (r < a)

			r = a;

	}

	cout << r << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.186341501609949x):
#include <cstdio>

#include <algorithm>

using namespace std;

#define LL long long

#define MAX_SIZE 1010

int n, m;

LL r, a;

LL x[MAX_SIZE], y[MAX_SIZE], z[MAX_SIZE], t[MAX_SIZE];



int main()

{

	scanf("%d %d", &n, &m);

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

		scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);



	int P[8][3] = { { 1,1,1 },{ 1,1,-1 },{ 1,-1,1 },{ 1,-1,-1 },{ -1,1,1 },{ -1,1,-1 },{ -1,-1,1 },{ -1,-1,-1 } };

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

		for (int j = 0; j < n; ++j)

			t[j] = x[j] * P[i][0] + y[j] * P[i][1] + z[j] * P[i][2];

		sort(t, t + n);

		a = 0;

		for (int k = n - m; k < n; ++k)

			a += t[k];

		if (r < a)

			r = a;

	}

	printf("%lld\n", r);

	return 0;

}