Problem:
Score : 900 points

Problem Statement

Let us consider a grid of squares with N rows and N columns. You want to put some domino pieces on this grid.
Each domino piece covers two squares that have a common side. Each square can be covered by at most one piece.

For each row of the grid, let's define its quality as the number of domino pieces that cover at least one square in this row.
We define the quality of each column similarly.

Find a way to put at least one domino piece on the grid so that the quality of every row is equal to the quality of every column,
or determine that such a placement doesn't exist.

Constraints

2 \le N \le 1000

Input

Input is given from Standard Input in the following format:

N

Output

If the required domino placement doesn't exist, print a single integer -1.

Otherwise, output your placement as N strings of N characters each.
If a square is not covered, the corresponding character must be . (a dot).
Otherwise, it must contain a lowercase English letter.
Squares covered by the same domino piece must contain the same letter.
If two squares have a common side but belong to different pieces, they must contain different letters.

Sample Input 1

6

Sample Output 1

aabb..
b..zz.
ba....
.a..aa
..a..b
..a..b

The quality of every row and every column is 2.

Sample Input 2

2

Sample Output 2

-1

Solution in Rust (1.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
    }

    if n == 2 {
        println!("-1");
        return;
    }
    if n == 3 {
        println!("aa.");
        println!("..b");
        println!("..b");
        return;
    }
    let x = n%4;
    let y = n/4 - 1;
    let mut c = vec![vec!['.'; n]; n];
    
    for i in 0..y {
        print(&mut c, i*4, 0);
    }
    print(&mut c, y*4, x);
    for i in 0..n {
        for j in 0..n {
            print!("{}", c[i][j]);
        } println!("");
    }
}

fn print(c: &mut Vec<Vec<char>>, x: usize, p: usize) {
    let t = [
        vec![
            "aacd",
            "bbcd",
            "efgg",
            "efhh",
        ],
        vec![
            "aabbc",
            "djj.c",
            "d..ih",
            "e..ih",
            "effgg",
        ],
        vec![
            "a.b.c.",
            "a.b.c.",
            "ddeeff",
            "gghhii",
            ".j.k.l",
            ".j.k.l",
        ],
        vec![
            "aabbcc.",
            "gg.hh.d",
            "..i..jd",
            "..i..je",
            "kk.ll.e",
            "..m..nf",
            "..m..nf",
        ],
    ];
    for i in 0..p+4 {
        for j in 0..p+4 {
            c[x+i][x+j] = t[p][i].chars().nth(j).unwrap();
        }
    }
}
*/

fn main() {
    let exe = "/tmp/bin366DD9B9";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";