Language: C

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

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||j==i+1) cout << "a";
                    else if(j==i+2) cout << "b";
                    else cout << ".";
                } else if(i%3==2){
                    if(j==i-1||j==i+1) cout << "b";
                    else cout << ".";
                } else {
                    if(j==i-2) cout << "b";
                    else if(j==i-1||j==i) cout << "a";
                    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||j==i+1) cout << "a";
                    else if(j==i+2) cout << "b";
                    else cout << ".";
                } else if(i%3==2){
                    if(j==i-1||j==i+1) cout << "b";
                    else cout << ".";
                } else {
                    if(j==i-2) cout << "b";
                    else if(j==i-1||j==i) cout << "a";
                    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:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.