Language: C++


import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int n = Integer.parseInt(std.next());

		int defaultpip[][] = new int[n][6];
		ArrayList<Dice> dc = new ArrayList<Dice>();

		for(int j=0; j<n; j++){
			for(int i=0; i<6; i++){
				defaultpip[j][i] = Integer.parseInt(std.next());
			}
			dc.add(new Dice(defaultpip[j]));
		}

		//??¬???????????¬???
		String query[] = {"S", "W", "N", "E"};

		boolean diff = false;
		ALLLOOP:
		for(int k=0; k<n-1; k++){
			for(int j=k+1; j<n; j++){
				diff = false;
				for(int i = 0; i<1000; i++){
					if(dc.get(k).issame(dc.get(j))){
						break ALLLOOP;
					}else{
						dc.set(k, dc.get(k).newnowpips(query[(int)(Math.random()*4)]));
					}
				}
				diff = true;
			}
		}
		if(diff){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

class Dice {
	int pips[];
	int nowpip;
	int spip;
	int epip;
	int wpip;
	int npip;
	int rpip;

	public Dice(int pip[]){
		this(pip, 0, 1, 2, 3, 4, 5);
	}

	public Dice(int pip[], int now, int s, int e, int w, int n, int r){
		pips = pip;
		nowpip = now;
		spip = s;
		epip = e;
		wpip = w;
		npip = n;
		rpip = r;
	}

	public Dice newnowpips(String query){
		if(query.equals("N")){
			return new Dice(pips,spip,rpip,epip,wpip,nowpip,npip);
		}else if(query.equals("E")){
			return new Dice(pips,wpip,spip,nowpip,rpip,npip,epip);
		}else if(query.equals("S")){
			return new Dice(pips,npip,nowpip,epip,wpip,rpip,spip);
		}else if(query.equals("W")){
			return new Dice(pips,epip,spip,rpip,nowpip,npip,wpip);
		}else {	//clockwise
			return new Dice(pips,nowpip,epip,npip,wpip,spip,rpip);
		}
	}

	public String showdice(){
		return pips[nowpip] +" "+ pips[spip] +" "+ pips[epip] +" "+ pips[wpip] +" "+ pips[npip] +" "+ pips[rpip];
	}

	public boolean issame(Dice d2){
		return showdice().equals(d2.showdice());
	}
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.ArrayList;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
a.cc:55:15: error: expected ':' before 'Dice'
   55 |         public Dice(int pip[]){
      |               ^~~~~
      |               :
a.cc:59:15: error: expected ':' before 'Dice'
   59 |         public Dice(int pip[], int now, int s, int e, int w, int n, int r){
      |               ^~~~~
      |               :
a.cc:69:15: error: expected ':' before 'Dice'
   69 |         public Dice newnowpips(String query){
      |               ^~~~~
      |               :
a.cc:69:32: error: 'String' has not been declared
   69 |         public Dice newnowpips(String query){
      |                                ^~~~~~
a.cc:83:15: error: expected ':' before 'String'
   83 |         public String showdice(){
      |               ^~~~~~~
      |               :
a.cc:83:16: error: 'String' does not name a type
   83 |         public String showdice(){
      |                ^~~~~~
a.cc:87:15: error: expected ':' before 'boolean'
   87 |         public boolean issame(Dice d2){
      |               ^~~~~~~~
      |               :
a.cc:87:16: error: 'boolean' does not name a type; did you mean 'bool'?
   87 |         public boolean issame(Dice d2){
      |                ^~~~~~~
      |                bool
a.cc:47:13: error: flexible array member 'Dice::pips' not at end of 'class Dice'
   47 |         int pips[];
      |             ^~~~
a.cc:90:2: error: expected ';' after class definition
   90 | }
      |  ^
      |  ;
a.cc: In constructor 'Dice::Dice(int*)':
a.cc:56:21: error: expression cannot be used as a function
   56 |                 this(pip, 0, 1, 2, 3, 4, 5);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc: In constructor 'Dice::Dice(int*, int, int, int, int, int, int)':
a.cc:60:17: error: invalid use of array with unspecified bounds
   60 |                 pips = pip;
      |                 ^~~~
a.cc: In member function 'Dice Dice::newnowpips(int)':
a.cc:70:26: error: request for member 'equals' in 'query', which is of non-class type 'int'
   70 |                 if(query.equals("N")){
      |                          ^~~~~~
a.cc:71:77: error: could not convert '(operator new(24), ((true, (((Dice*)<anonymous>)->Dice::Dice(((int*)(&((Dice*)this)->Dice::pips)), ((Dice*)this)->Dice::spip, ((Dice*)this)->Dice::rpip, ((Dice*)this)->Dice::epip, ((Dice*)this)->Dice::wpip, ((Dice*)this)->Dice::nowpip, ((Dice*)this)->Dice::npip), (<anonymous> = false))), ((Dice*)<anonymous>)))' from 'Dice*' to 'Dice'
   71 |                         return new Dice(pips,spip,rpip,epip,wpip,nowpip,npip);
      |                                                                             ^
      |                                                                             |
      |                                                                             Dice*
a.cc:72:32: error: request for member 'equals' in 'query', which is of non-class type 'int'
   72 |                 }else if(query.equals("E")){
      |                                ^~~~~~
a.cc:73:77: error: could not convert '(operator new(24), ((true, (((Dice*)<anonymous>)->Dice::Dice(((int*)(&((Dice*)this)->Dice::pips)), ((Dice*)this)->Dice::wpip, ((Dice*)this)->Dice::spip, ((Dice*)this)->Dice::nowpip, ((Dice*)this)->Dice::rpip, ((Dice*)this)->Dice::npip, ((Dice*)this)->Dice::epip), (<anonymous> = false))), ((Dice*)<anonymous>)))' from 'Dice*' to 'Dice'
   73 |                         return new Dice(pips,wpip,spip,nowpip,rpip,npip,epip);
      |                                                                             ^
      |                                                                             |
      |                                                                             Dice*
a.cc:74:32: error: request for member 'equals' in 'query', which is of non-class type 'int'
   74 |                 }else if(query.equals("S")){
      |                                ^~~~~~
a.cc:75:77: error: could not convert '(operator new(24), ((true, (((Dice*)<anonymous>)->Dice::Dice(((int*)(&((Dice*)this)->Dice::pips)), ((Dice*)this)->Dice::npip, ((Dice*)this)->Dice::nowpip, ((Dice*)this)->Dice::epip, ((Dice*)this)->Dice::wpip, ((Dice*)this)->Dice::rpip, ((Dice*)this)->Dice::spip), (<anonymous> = false))), ((Dice*)<anonymous>)))' from 'Dice*' to 'Dice'
   75 |                         return new Dice(pips,npip,nowpip,epip,wpip,rpip,spip);
      |                                                                             ^
      |                                                                             |
      |                                                                             Dice*
a.cc:76:32: error: request for member 'equals' in 'query', which is of non-class type 'int'
   76 |                 }else if(query.equals("W")){
      |                                ^~~~~~
a.cc:77:77: error: could not convert '(operator new(24), ((true, (((Dice*)<anonymous>)->Dice::Dice(((int*)(&((Dice*)this)->Dice::pips)), ((Dice*)this)->Dice::epip, ((Dice*)this)->Dice::spip, ((Dice*)this)->Dice::rpip, ((Dice*)this)->Dice::nowpip, ((Dice*)this)->Dice::npip, ((Dice*)this)->Dice::wpip), (<anonymous> = false))), ((Dice*)<anonymous>)))' from 'Dice*' to 'Dice'
   77 |                         return new Dice(pips,epip,spip,rpip,nowpip,npip,wpip);
      |                                                                             ^
      |                                                                             |
      |                                                                             Dice*
a.cc:79:77: error: could not convert '(operator new(24), ((true, (((Dice*)<anonymous>)->Dice::Dice(((int*)(&((Dice*)this)->Dice::pips)), ((Dice*)this)->Dice::nowpip, ((Dice*)this)->Dice::epip, ((Dice*)this)->Dice::npip, ((Dice*)this)->Dice::wpip, ((Dice*)this)->Dice::spip, ((Dice*)this)->Dice::rpip), (<anonymous> = false))), ((Dice*)<anonymous>)))' from 'Dice*' to 'Dice'
   79 |                         return new Dice(pips,nowpip,epip,npip,wpip,spip,rpip);
      |                                                                             ^
      |                                                                             |
      |                                                                             Dice*