Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int;

int main() {
    // your code goes here
    ll n,i,j;
    cin >> n;
    if(n%3==0){
        for(i=1;i<=n;i++){
            for(j=1;j<=n;j++){
                if(i%3==1){
                    if(j==i) cout << "a";
                    else cout << ".";
                } else if(i%3==2){
                    if(j==i-1) cout << "a";
                    else cout << ".";
                } else {
                    if(j==i-1||j==i) cout << "b";
                    else cout << ".";
                }
            }
            cout << endl;
        }
    } else if(n%4==0) {
        for(i=1;i<=n;i++){
            for(j=1;j<=n;j++){
                if(i%4==1){
                    if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else if(j==i+2||j==i+3) cout << "c";
                    else cout << ".";
                } else if(i%4==2){
                    if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else if(j==i+1||j==i+2) cout << "d";
                    else cout << ".";
                } else if(i%4==3){
                    if(j==i-2||j==i-1) cout << "c";
                    else if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else cout << ".";
                } else {
                    if(j==i-3||j==i-2) cout << "d";
                    else if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else cout << ".";
                }
            }
            cout << endl;
        }
    } else if(n%3==1) {
        for(i=1;i<=n-4;i++){
            for(j=1;j<=n;j++){
                if(i%3==1){
                    if(j==i) cout << "a";
                    else cout << ".";
                } else if(i%3==2){
                    if(j==i-1) cout << "a";
                    else cout << ".";
                } else {
                    if(j==i-1||j==i) cout << "b";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        for(i=n-3;i<=n;i++){
            for(j=1;j<=n;j++){
                if(i==n-3){
                    if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else if(j==i+2||j==i+3) cout << "c";
                    else cout << ".";
                } else if(i==n-2){
                    if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else if(j==i+1||j==i+2) cout << "d";
                    else cout << ".";
                } else if(i==n-1){
                    if(j==i-2||j==i-1) cout << "c";
                    else if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else cout << ".";
                } else {
                    if(j==i-3||j==i-2) cout << "d";
                    else if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else cout << ".";
                }
            }
            cout << endl;
        }
    } else if(n>=8){
        for(i=1;i<=n-8;i++){
            for(j=1;j<=n;j++){
                if(i%3==1){
                    if(j==i) cout << "a";
                    else cout << ".";
                } else if(i%3==2){
                    if(j==i-1) cout << "a";
                    else cout << ".";
                } else {
                    if(j==i-1||j==i) cout << "b";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        for(i=n-7;i<=n-4;i++){
            for(j=1;j<=n;j++){
                if(i==n-7){
                    if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else if(j==i+2||j==i+3) cout << "c";
                    else cout << ".";
                } else if(i==n-6){
                    if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else if(j==i+1||j==i+2) cout << "d";
                    else cout << ".";
                } else if(i==n-5){
                    if(j==i-2||j==i-1) cout << "c";
                    else if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else cout << ".";
                } else {
                    if(j==i-3||j==i-2) cout << "d";
                    else if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        for(i=n-3;i<=n;i++){
            for(j=1;j<=n;j++){
                if(i==n-3){
                    if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else if(j==i+2||j==i+3) cout << "c";
                    else cout << ".";
                } else if(i==n-2){
                    if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else if(j==i+1||j==i+2) cout << "d";
                    else cout << ".";
                } else if(i==n-1){
                    if(j==i-2||j==i-1) cout << "c";
                    else if(j==i) cout << "a";
                    else if(j==i+1) cout << "b";
                    else cout << ".";
                } else {
                    if(j==i-3||j==i-2) cout << "d";
                    else if(j==i-1) cout << "a";
                    else if(j==i) cout << "b";
                    else cout << ".";
                }
            }
            cout << endl;
        }
    } else {
        cout << "-1" << endl;
    }
    return 0;
}

Compiler output:
a.cc:3:19: error: declaration does not declare anything [-fpermissive]
    3 | typedef long long int;
      |                   ^~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'll' was not declared in this scope
    7 |     ll n,i,j;
      |     ^~
a.cc:8:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |     cin >> n;
      |            ^
      |            yn
a.cc:10:13: error: 'i' was not declared in this scope
   10 |         for(i=1;i<=n;i++){
      |             ^
a.cc:11:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   11 |             for(j=1;j<=n;j++){
      |                 ^
      |                 jn
a.cc:26:13: error: 'i' was not declared in this scope
   26 |         for(i=1;i<=n;i++){
      |             ^
a.cc:27:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   27 |             for(j=1;j<=n;j++){
      |                 ^
      |                 jn
a.cc:53:13: error: 'i' was not declared in this scope
   53 |         for(i=1;i<=n-4;i++){
      |             ^
a.cc:54:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   54 |             for(j=1;j<=n;j++){
      |                 ^
      |                 jn
a.cc:68:13: error: 'i' was not declared in this scope
   68 |         for(i=n-3;i<=n;i++){
      |             ^
a.cc:69:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   69 |             for(j=1;j<=n;j++){
      |                 ^
      |                 jn
a.cc:95:13: error: 'i' was not declared in this scope
   95 |         for(i=1;i<=n-8;i++){
      |             ^
a.cc:96:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   96 |             for(j=1;j<=n;j++){
      |                 ^
      |                 jn
a.cc:110:13: error: 'i' was not declared in this scope
  110 |         for(i=n-7;i<=n-4;i++){
      |             ^
a.cc:111:17: error: 'j' was not declared in this scope; did you mean 'jn'?
  111 |             for(j=1;j<=n;j++){
      |                 ^
      |                 jn
a.cc:136:13: error: 'i' was not declared in this scope
  136 |         for(i=n-3;i<=n;i++){
      |             ^
a.cc:137:17: error: 'j' was not declared in this scope; did you mean 'jn'?
  137 |             for(j=1;j<=n;j++){
      |                 ^
      |                 jn