#include <iostream>
#include <vector>
using namespace std;
#define MAXN 6
vector<vector<vector<int> > > v = { { {0,0,0,1},{1,1,1,1},{0,0,1,0} },
{ {0,0,0,1},{1,1,1,1},{0,1,0,0} },
{ {0,0,0,1},{1,1,1,1},{1,0,0,0} },
{ {0,0,1,0},{1,1,1,1},{0,0,1,0} },
{ {0,0,1,0},{1,1,1,1},{0,1,0,0} },
{ {0,0,1,1},{1,1,1,0},{0,1,0,0} },
{ {0,0,1,1,1},{1,1,1,0,0} },
{ {0,0,1,1},{1,1,1,0},{0,0,1,0} },
{ {0,0,1,1},{1,1,1,0},{1,0,0,0} },
{ {0,0,1,1},{0,1,1,0},{1,1,0,0} },
{ {0,0,0,1},{1,1,1,1},{0,0,0,1} } };
int map[MAXN][MAXN];
bool flag;
void rotate(vector<vector<int> >& vt){
int N = vt.size();
int M = vt[0].size();
vector<vector<int> > tmp(M,vector<int>(N));
for (int i = 0; i < N; i++){
for (int j = 0;j <M; j++){
tmp[j][N-i-1] = vt[i][j];
}
}
vt = tmp;
}
void flip(vector<vector<int> >& vt){
int N = vt.size();
int M = vt[0].size();
vector<vector<int> > tmp(N,vector<int>(M));
for (int i = 0 ;i < N; i++){
for (int j = 0 ;j<M;j++){
tmp[i][M-j-1] = vt[i][j];
}
}
vt = tmp;
}
bool is_match(int x, int y, vector<vector<int> > vt){
int N = vt.size();
int M = vt[0].size();
for (int i = 0; i <N; i++){
for (int j=0;j<M;j++){
if (map[i+x][j+y] != vt[i][j]) return false;
}
}
return true;
}
void simulate(vector<vector<int> > vt){
for (int i = 0 ; i< 4; i++){
for (int j = 0 ;j < 2; j++){
if (i && !j) rotate(vt);
if (j) flip(vt);
int N = vt.size();
int M = vt[0].size();
for (int x = 0 ; x <= MAXN-N; x++){
for (int y = 0 ; y <= MAXN-M; y++){
if (is_match(x,y,vt)) {
flag = true;
return;
}
}
}
if (j) flip(vt);
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int time = 3;
while (time--){
flag = false;
for (int i = 0 ;i < MAXN; i++){
for (int j = 0;j<MAXN; j++){
cin >> map[i][j];
}
}
for (int i = 0 ;i < v.size(); i++){
simulate(v[i]);
if (flag) {
break;
}
}
if (flag) cout <<"yes\n";
else cout <<"no\n";
}
return 0;
}