Language: C++

#include <iostream>
using namespace std;

class Dice
{
public:
	long top, front, right, left, back, bottom;
	Dice(long top, long front, long right, long left, long back, long bottom);
	void north();
	void south();
	void west();
	void east();
	void adjustTop(long top);
	void rotateRight();
};

Dice::Dice(long top, long front, long right, long left, long back, long bottom){
	this->top = top;
	this->front = front;
	this->right = right;
	this->left = left;
	this->back = back;
	this->bottom = bottom;
}

void Dice::north(){
	long sv[6];
	sv[0] = this->front;
	sv[1] = this->bottom;
	sv[2] = this->right;
	sv[3] = this->left;
	sv[4] = this->top;
	sv[5] = this->back;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::south(){
	long sv[6];
	sv[0] = this->back;
	sv[1] = this->top;
	sv[2] = this->right;
	sv[3] = this->left;
	sv[4] = this->bottom;
	sv[5] = this->front;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::west(){
	long sv[6];
	sv[0] = this->right;
	sv[1] = this->front;
	sv[2] = this->bottom;
	sv[3] = this->top;
	sv[4] = this->back;
	sv[5] = this->left;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::east(){
	long sv[6];
	sv[0] = this->left;
	sv[1] = this->front;
	sv[2] = this->top;
	sv[3] = this->bottom;
	sv[4] = this->back;
	sv[5] = this->right;

	this->top = sv[0];
	this->front = sv[1];
	this->right = sv[2];
	this->left = sv[3];
	this->back = sv[4];
	this->bottom = sv[5];
}

void Dice::adjustTop(long top){
	if (top == this->front) Dice::north();
	else if (top == this->right) Dice::west();
	else if (top == this->left) Dice::east();
	else if (top == this->back) Dice::south();
	else if (top == this->bottom) for (long i = 0; i < 2; i++) Dice::north();
}

void Dice::rotateRight(){
	long sv[4];
	sv[0] = this->front;
	sv[1] = this->right;
	sv[2] = this->left;
	sv[3] = this->back;

	this->front = sv[1];
	this->right = sv[0];
	this->left = sv[3];
	this->back = sv[2];
}

int main(){
	long n;
	cin >> n;
	long top1, front1, right1, left1, back1, bottom1;
	cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
	Dice *dice;
	while (cin >> top >> front >> right >> left >> back >> bottom){
		long top, front, right, left, back, bottom;
		dice = new Dice(top, front, right, left, back, bottom);
		dice->adjustTop(top1);
		for (long i = 0; i < 3; i++){
			if (d->front != front1) d->rotateRight();
		}
		if (d->top == top1 && d->front == front1 && d->right == right1){
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
		delete dice;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:121:23: error: 'top' was not declared in this scope; did you mean 'top1'?
  121 |         while (cin >> top >> front >> right >> left >> back >> bottom){
      |                       ^~~
      |                       top1
a.cc:121:30: error: 'front' was not declared in this scope; did you mean 'front1'?
  121 |         while (cin >> top >> front >> right >> left >> back >> bottom){
      |                              ^~~~~
      |                              front1
a.cc:121:56: error: 'back' was not declared in this scope; did you mean 'back1'?
  121 |         while (cin >> top >> front >> right >> left >> back >> bottom){
      |                                                        ^~~~
      |                                                        back1
a.cc:121:64: error: 'bottom' was not declared in this scope; did you mean 'bottom1'?
  121 |         while (cin >> top >> front >> right >> left >> back >> bottom){
      |                                                                ^~~~~~
      |                                                                bottom1
a.cc:126:29: error: 'd' was not declared in this scope
  126 |                         if (d->front != front1) d->rotateRight();
      |                             ^
a.cc:128:21: error: 'd' was not declared in this scope
  128 |                 if (d->top == top1 && d->front == front1 && d->right == right1){
      |                     ^