Language: C++

#include <iostream>
using namespace std;


#define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
#define m tmp=d[r][1];d[r][1]=d[r][3];d[r][3]=d[r][4];d[r][4]=d[r][2];d[r][2]=tmp;
#define y tmp=d[r][0];d[r][0]=d[r][3];d[r][3]=d[r][5];d[r][5]=d[r][2];d[r][2]=tmp;

int main(){
 int tmp,cnt,j,a=1,i,k,n,c=0;

 cin >> n;

 int d[n][6];

 for(i=0;i<n;i++){
  for(j=0;j<6;j++){
   cin >> d[i][j] ;
  }
 }

 for(i=0;i<n-1;i++){
  check
  if(cnt==6)a=0;

 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    r
   }
   check
   if(cnt==6)break;
   tmp=d[r][0];
   d[r][0]=d[r][1];
   d[r][1]=d[r][5];
   d[r][5]=d[r][4];
   d[r][4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  if(cnt==6)break;
  y
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  if(cnt==6)break;
  a=0;
 }
 }

 if(i==n-2)cout << "Yes" << endl;
 else cout << "No" << endl;

 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:42: error: 'q' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                          ^
a.cc:23:3: note: in expansion of macro 'check'
   23 |   check
      |   ^~~~~
a.cc:5:51: error: 'r' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                                   ^
a.cc:23:3: note: in expansion of macro 'check'
   23 |   check
      |   ^~~~~
a.cc:5:42: error: 'q' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                          ^
a.cc:29:5: note: in expansion of macro 'check'
   29 |     check
      |     ^~~~~
a.cc:5:51: error: 'r' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                                   ^
a.cc:29:5: note: in expansion of macro 'check'
   29 |     check
      |     ^~~~~
a.cc:31:5: error: 'r' was not declared in this scope
   31 |     r
      |     ^
a.cc:5:42: error: 'q' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                          ^
a.cc:33:4: note: in expansion of macro 'check'
   33 |    check
      |    ^~~~~
a.cc:5:51: error: 'r' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                                   ^
a.cc:33:4: note: in expansion of macro 'check'
   33 |    check
      |    ^~~~~
a.cc:35:10: error: 'r' was not declared in this scope
   35 |    tmp=d[r][0];
      |          ^
a.cc:7:17: error: 'r' was not declared in this scope
    7 | #define y tmp=d[r][0];d[r][0]=d[r][3];d[r][3]=d[r][5];d[r][5]=d[r][2];d[r][2]=tmp;
      |                 ^
a.cc:42:3: note: in expansion of macro 'y'
   42 |   y
      |   ^
a.cc:5:42: error: 'q' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                          ^
a.cc:44:4: note: in expansion of macro 'check'
   44 |    check
      |    ^~~~~
a.cc:46:5: error: expected ';' before '}' token
   46 |    r
      |     ^
      |     ;
   47 |   }
      |   ~  
a.cc:5:42: error: 'q' was not declared in this scope
    5 | #define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
      |                                          ^
a.cc:52:4: note: in expansion of macro 'check'
   52 |    check
      |    ^~~~~
a.cc:54:5: error: expected ';' before '}' token
   54 |    r
      |     ^
      |     ;
   55 |   }
      |   ~