/*
????????????????????¨?????????????????£??????????????????????????????

?±????????????\???????§?????????¢??????
1
4235
   6
??\???????§???????????????\??????
0
1234
   5
?????????????????°?????????????°????????????????0?????\????????????rotate??????
????????????1~4????????????????°????????????????1?????\????????????rotate??????
0~5?????§?????°????????????100?????????????¶????????????????
???????????°????????£????????§??????

??????????????????????????¨?????????????????????

*/
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>

//--- --- --- debug function --- --- ---
// #define DEBUG // switch this macro
#ifdef DEBUG
#include <cstdio>
typedef int (*printf_t)(const char* format, ...);
printf_t printfd = std::printf;
#else
int printfd(const char* format, ...){return 0;}
#endif
//--- --- --- debug function --- --- ---
// class TDie
// {
//     std::vector<int> FTable;
//     std::vector<int> FSide;
// public:
//     TDie(const string& str)
//     {
//         FTable.resize(2);
//         FSide.resize(4);
//         std::stringstream ss;
//         ss << str;
//         ss >> FTable[0] >> FSize[0] >> FSize[1] >> FSize[3] >> FSize[2] >> FTable[1];
        
//         std::sort(FTable);
//         std::sort(FSide);
//     }
//     bool operator < (const TDie& Die)
//     {
        
//     }
// };


void GetNumList(std::vector<int>* NumList, std::vector<int> PipList)
{
    for(int i = 0; i < 6; ++i){
        int num = 0;
        for(int j = 0; j < 6; ++j){
            num *= 10;
            num += PipList[j];
        }
        NumList->push_back(num);
        // printfd("%d\n", num);
        std::rotate(PipList.begin(), PipList.begin()+1, PipList.end());
    }
}
int ToNum(std::vector<int> PipList)
{
    int num = 0;
    for(int i = 0; i < 6; ++i){
        num *= 10;
        num += PipList[i];
    }
    return num;
}
int Normalize(std::string str)
{
    std::vector<int> PipList(6);
    std::stringstream ss;
    ss << str;
    // ss >> PipList[0] >> PipList[1] >> PipList[2] >> PipList[3] >> PipList[4] >> PipList[5];
    ss >> PipList[0] >> PipList[2] >> PipList[3] >> PipList[1] >> PipList[4] >> PipList[5];
    // std::cout << str << std::endl;
    // std::cout << PipList[0] << PipList[1] << PipList[2] << PipList[3] << PipList[4] << PipList[5] << std::endl;
    
    // ?°???????????????????????????£?????????
    printfd("Num:%d\n", ToNum(PipList));
    std::vector<int>::iterator min = std::min_element(PipList.begin(), PipList.end());
    if(min == PipList.begin()+0){
        // ??????????????????
    }else
    if(min == PipList.begin()+5){
        std::reverse(PipList.begin(), PipList.end());
    }else
    {
        int distance = std::distance(PipList.begin(), std::min_element(PipList.begin()+1, PipList.begin()+5));
        printfd("min distance:%d\n", distance);
        std::rotate(PipList.begin()+1, PipList.begin() +  distance, PipList.begin()+5);
        printfd("Num:%d\n", ToNum(PipList));
        int temp = PipList[0];
        PipList[0] = PipList[1];
        PipList[1] = PipList[5];
        PipList[5] = PipList[3];
        PipList[3] = temp;
    }
    
    // if(PipList[0] > PipList[5]){
    //     std::reverse(PipList.begin(), PipList.end());
    //     printfd("reverse\n");
    // }
    
    printfd("Num:%d\n", ToNum(PipList));
    int distance = std::distance(PipList.begin(), std::min_element(PipList.begin()+1, PipList.begin()+5));
    printfd("min distance:%d\n", distance);
    std::rotate(PipList.begin()+1, PipList.begin() +  distance, PipList.begin()+5);
    
    return ToNum(PipList);
    
    // std::vector<int> NumList;
    // GetNumList(&NumList, PipList);
    // std::reverse(PipList.begin(), PipList.end());
    // GetNumList(&NumList, PipList);
    // return *std::min_element(NumList.begin(), NumList.end());
}

int main()
{
    int n;
    std::cin >> n;
    std::cin.ignore();
    
    std::vector<int> NormalizedList;
    for(int i = 0; i < n; ++i){
        std::string str;
        std::getline(std::cin, str);
        int Normalized = Normalize(str);
        NormalizedList.push_back(Normalized);
        printfd("\n%d\n", Normalized);
    }

    std::sort(NormalizedList.begin(), NormalizedList.end());
    std::vector<int>::iterator i = std::unique(NormalizedList.begin(), NormalizedList.end());
    if(i == NormalizedList.end()){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1248