int a[25];
int b[7][9]=
{
{0},
{0,1,3,5,7,9,11,24,22},
{0,2,4,6,8,10,12,23,21},
{0,1,2,18,20,12,11,15,13},
{0,3,4,17,19,10,9,16,14},
{0,5,6,17,18,21,22,13,14},
{0,7,8,19,20,23,24,15,16}
};
void spin(int x)
{
int c[3]= {0};
for(int i=1; i<=2; i++)
c[i]=a[b[x][i]];
for(int i=1; i<=6; i++)
a[b[x][i]]=a[b[x][i+2]];
for(int i=7; i<=8; i++)
a[b[x][i]]=c[i-6];
}
bool solved(void)
{
for(int i=1; i<=24; i+=4)
for(int j=i+1; j<=i+3; j++)
if(a[j]!=a[i])return false;
return true;
}
int main()
{
for(int i=1; i<=24; i++)
scanf("%d",&a[i]);
for(int i=1;i<=6;i++)
{
spin(i);
if(solved())return 0*puts("YES");
spin(i),spin(i);
if(solved())return 0*puts("YES");
spin(i);
}
puts("NO");
return 0;
}