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 top, front, right, left, back, bottom;
	cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
	Dice *dice;
	while (cin >> 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:119:16: error: 'top1' was not declared in this scope; did you mean 'top'?
  119 |         cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
      |                ^~~~
      |                top
a.cc:119:24: error: 'front1' was not declared in this scope; did you mean 'front'?
  119 |         cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
      |                        ^~~~~~
      |                        front
a.cc:119:34: error: 'right1' was not declared in this scope; did you mean 'right'?
  119 |         cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
      |                                  ^~~~~~
      |                                  right
a.cc:119:44: error: 'left1' was not declared in this scope; did you mean 'left'?
  119 |         cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
      |                                            ^~~~~
      |                                            left
a.cc:119:53: error: 'back1' was not declared in this scope; did you mean 'back'?
  119 |         cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
      |                                                     ^~~~~
      |                                                     back
a.cc:119:62: error: 'bottom1' was not declared in this scope; did you mean 'bottom'?
  119 |         cin >> top1 >> front1 >> right1 >> left1 >> back1 >> bottom1;
      |                                                              ^~~~~~~
      |                                                              bottom
a.cc:125:29: error: 'd' was not declared in this scope
  125 |                         if (d->front != front1) d->rotateRight();
      |                             ^
a.cc:127:21: error: 'd' was not declared in this scope
  127 |                 if (d->top == top1 && d->front == front1 && d->right == right1){
      |                     ^