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:12:35: error: 'S4' was not declared in this scope
   12 |                 s[n + i][n + j] = S4[i][j];
      |                                   ^~
a.cc:16:35: error: 'S5' was not declared in this scope
   16 |                 s[n + i][n + j] = S5[i][j];
      |                                   ^~
a.cc:20:35: error: 'S6' was not declared in this scope
   20 |                 s[n + i][n + j] = S6[i][j];
      |                                   ^~
a.cc:24:35: error: 'S7' was not declared in this scope
   24 |                 s[n + i][n + j] = S7[i][j];
      |                                   ^~
a.cc: In function 'int main()':
a.cc:29:13: error: 'ri' was not declared in this scope
   29 |     int n = ri;
      |             ^~
a.cc:30:23: error: 'puts' was not declared in this scope
   30 |     if(n <= 2) return puts("-1"), 0;
      |                       ^~~~
a.cc:32:9: error: 'puts' was not declared in this scope
   32 |         puts("a..");
      |         ^~~~
a.cc:48:13: error: 'putchar' was not declared in this scope; did you mean 'char'?
   48 |             putchar(s[i][j]);
      |             ^~~~~~~
      |             char
a.cc:49:9: error: 'puts' was not declared in this scope
   49 |         puts("");
      |         ^~~~