Language: C++

const string S4[4] = {"abcc", "abdd", "ccab", "ddab"};
const string S5[5] = {"abbcc", "ad..a", "bd..a", "b.eez", "oorrz"};
const string S6[6] = {"oorrzz", ".a.b.c", ".a.b.c", "d.e.f.", "d.e.f.", "oorrzz"};
const string S7[7] = {".oorrzz", "oabb...", "oa.c...", "rddc...", "r...abb", "z...a.c", "z...ddc"};
char s[1010][1010];
inline void solve(int&n, int x) {
    if(x == 4)
        for(int i = 0; i < x; i++)
            for(int j = 0; j < x; j++)
                s[n + i][n + j] = S4[i][j];
    if(x == 5)
        for(int i = 0; i < x; i++)
            for(int j = 0; j < x; j++)
                s[n + i][n + j] = S5[i][j];
    if(x == 6)
        for(int i = 0; i < x; i++)
            for(int j = 0; j < x; j++)
                s[n + i][n + j] = S6[i][j];
    if(x == 7)
        for(int i = 0; i < x; i++)
            for(int j = 0; j < x; j++)
                s[n + i][n + j] = S7[i][j];
    n += x;
}

int main() {
    int n = ri;
    if(n <= 2) return puts("-1"), 0;
    if(n == 3) {
        puts("a..");
        puts("a..");
        puts(".bb");
        return 0;
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            s[i][j] = '.';
    int x = n % 4, N = 1;
    if(x == 0) solve(N, 4);
    if(x == 1) solve(N, 5);
    if(x == 2) solve(N, 6);
    if(x == 3) solve(N, 7);
    while(N <= n) solve(N, 4);
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++)
            putchar(s[i][j]);
        puts("");
    }
    return 0;

Compiler output:
a.cc:1:7: error: 'string' does not name a type
    1 | const string S4[4] = {"abcc", "abdd", "ccab", "ddab"};
      |       ^~~~~~
a.cc:2:7: error: 'string' does not name a type
    2 | const string S5[5] = {"abbcc", "ad..a", "bd..a", "b.eez", "oorrz"};
      |       ^~~~~~
a.cc:3:7: error: 'string' does not name a type
    3 | const string S6[6] = {"oorrzz", ".a.b.c", ".a.b.c", "d.e.f.", "d.e.f.", "oorrzz"};
      |       ^~~~~~
a.cc:4:7: error: 'string' does not name a type
    4 | const string S7[7] = {".oorrzz", "oabb...", "oa.c...", "rddc...", "r...abb", "z...a.c", "z...ddc"};
      |       ^~~~~~
a.cc: In function 'void solve(int&, int)':
a.cc:10:35: error: 'S4' was not declared in this scope
   10 |                 s[n + i][n + j] = S4[i][j];
      |                                   ^~
a.cc:14:35: error: 'S5' was not declared in this scope
   14 |                 s[n + i][n + j] = S5[i][j];
      |                                   ^~
a.cc:18:35: error: 'S6' was not declared in this scope
   18 |                 s[n + i][n + j] = S6[i][j];
      |                                   ^~
a.cc:22:35: error: 'S7' was not declared in this scope
   22 |                 s[n + i][n + j] = S7[i][j];
      |                                   ^~
a.cc: In function 'int main()':
a.cc:27:13: error: 'ri' was not declared in this scope
   27 |     int n = ri;
      |             ^~
a.cc:28:23: error: 'puts' was not declared in this scope
   28 |     if(n <= 2) return puts("-1"), 0;
      |                       ^~~~
a.cc:30:9: error: 'puts' was not declared in this scope
   30 |         puts("a..");
      |         ^~~~
a.cc:46:13: error: 'putchar' was not declared in this scope; did you mean 'char'?
   46 |             putchar(s[i][j]);
      |             ^~~~~~~
      |             char
a.cc:47:9: error: 'puts' was not declared in this scope
   47 |         puts("");
      |         ^~~~
a.cc:49:14: error: expected '}' at end of input
   49 |     return 0;
      |              ^
a.cc:26:12: note: to match this '{'
   26 | int main() {
      |            ^