// Written by newbiechd
#include <cstring>
#include <iostream>
#include <string>

const int maxN = 13;
int n;
char col[maxN][maxN];
bool vis[26];
void dfs(int x, int y, char c) {
  if (x > n) {
    int val = 0;
    memset(vis, 0, sizeof(vis));
    for (int j = 1; j <= n; ++j) vis[col[1][j] - 'a'] = 1;
    for (char t = 'a'; t <= c; ++t) val += vis[t - 'a'];
    if (val != 3)
      return ;
    for (int i = 2; i <= n; ++i) {
      memset(vis, 0, sizeof(vis));
      int tmp = 0;
      for (int j = 1; j <= n; ++j) vis[col[i][j] - 'a'] = 1;
      for (char t = 'a'; t <= c; ++t) tmp += vis[t - 'a'];
      if (tmp != val)
        return ;
    }
    for (int j = 1; j <= n; ++j) {
      memset(vis, 0, sizeof(vis));
      int tmp = 0;
      for (int i = 1; i <= n; ++i) vis[col[i][j] - 'a'] = 1;
      for (char t = 'a'; t <= c; ++t) tmp += vis[t - 'a'];
      if (tmp != val)
        return ;
    }
    for (int i = 1; i <= n; ++i)
      printf("%s\n", col[i] + 1);
    putchar('\n'), fflush(stdout);
    return ;
  }
  if (y > n) {
    dfs(x + 1, 1, c);
    return ;
  }
  if (col[x][y - 1] == '.') {
    col[x][y] = col[x][y - 1] = c;
    dfs(x, y + 1, c + 1);
    col[x][y] = col[x][y - 1] = '.';
  }
  if (col[x - 1][y] == '.') {
    col[x][y] = col[x - 1][y] = c;
    dfs(x, y + 1, c + 1);
    col[x][y] = col[x - 1][y] = '.';
  }
  dfs(x, y + 1, c);
}

const std::string ans[][7] = {
  {
    "aabc",
    "ddbc",
    "efgg",
    "efhh"
  },
  {
    "aabbd",
    "ccf.d",
    "eefgg",
    "..hij",
    "..hij"
  },
  {
    "aabbcc",
    "ddeeff",
    "ghi...",
    "ghi...",
    "...jkl",
    "...jkl"
  },
  {
    "aabbcc.",
    "ddee..h",
    "ffgg..h",
    "....ijk",
    "....ijk",
    "....lmn",
    "....lmn"
  }
};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cin >> n;
  /*
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      col[i][j] = '.';
  dfs(1, 1, 'a');
  */
  
  if (n < 3) {
    printf("-1\n");
    return 0;
  }
  if (n == 3) {
    std::cout << "aa.\n..a\n..a\n";
    return 0;
  }

  int k = (n & 3) + 4;
  for (int i = 0; i < n - k; ++i) {
    std::string str(n, '.');
    str.replace(i / 4 * 4, 4, ans[0][i % 4]);
    std::cout << str << '\n';
  }
  for (int i = n - k; i < n; ++i) {
    std::string str(n, '.');
    str.replace(n - k, k, ans[k - 4][i + k - n]);
    std::cout << str << '\n';
  }
  return 0;
}

#include<iostream>
using namespace std;
#include<string>

class dice
{
public:
    int F[6];
    int q1, q2;
    dice();
	void input();
    void roll_a();
    void roll_b();
    bool check(const dice& d);
    bool equal(const dice& d);
};

dice::dice(){}

void dice::input()
{
    int i;
    for(i = 0; i < 6; i++) cin >> F[i];
    q1 = F[0] + F[1] + F[2] + F[3] + F[4] + F[5];
    q2 = F[0] * F[5] + F[1] * F[4] + F[2] * F[3];
}

void dice::roll_a()
{
    int i;
    i = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = i;
    i = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = i;
}

void dice::roll_b()
{
    int i;
    i = F[0]; F[0] = F[5]; F[5] = i;
    i = F[1]; F[1] = F[3]; F[3] = i;
    i = F[2]; F[2] = F[4]; F[4] = i;
}
 
bool dice::check(const dice& d)
{
    int l, m;
    if((d.F[0] != F[0]) || (d.F[5] != F[5])) return false;

    for(l = 1; l <= 4; l++){
        for(m = 1; m <= 4; m++){
            if(d.F[m] != F[(l * m) % 5]) break;
        }
        if(m == 5) return true;
    }
    return false;
}

bool dice::equal(const dice& d)
{
    bool eq;
    if((q1 != d.q1) || (q2 != d.q2)) return false;
    for(int i = 0; i < 2; i++){
        eq = check(d);
        if(!eq){ roll_a(); eq = check(d); }
        if(!eq){ roll_a(); eq = check(d); }
        if(eq || i == 1) break;
        roll_b();
    }
    return eq;
}

int main()
{
    dice d[100];
    int n, i, j;

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

    for(i = 0; i < n; i++){
        for(j = i + 1; j < n; j++){
            if(d[i].equal(d[j])) break;
        }
        if(j < n) break;
    }
    if(i + j == 2 * n){ cout << "Yes"; }else{ cout << "No"; }
    cout << endl;

    return 0;
}