Buggy python submission (verdict: Runtime Error):
n = int(input())

if n == 2 or n == 7:
    print(-1)
    exit

if n % 3 == 0:
    for i in range(n):
        br = ['.'] * n
        if i % 3 == 0:
            k = i // 3
            br[3*k] = 'a'
            br[3*k+1] = 'a'
        else:
            k = i // 3
            br[3*k+2] = 'a'
        print(''.join( br))
    exit()
ac = n % 4
afive = ac
afour = (n - afive * 5) // 4
for i in range(n):
    if i // 4 < afour:
        br = ['.'] * n
        if i % 4 == 0:
            k = i // 4
            br[4*k] = 'a'
            br[4*k+1] = 'a'
            br[4*k+2] = 'b'
            br[4*k+3] = 'c'
        if i % 4 == 1:
            k = i // 4
            br[4*k] = 'd'
            br[4*k+1] = 'd'
            br[4*k+2] = 'b'
            br[4*k+3] = 'c'
        if i % 4 == 2:
            k = i // 4
            br[4*k] = 'e'
            br[4*k+1] = 'f'
            br[4*k+2] = 'g'
            br[4*k+3] = 'g'
        if i % 4 == 3:
            k = i // 4
            br[4*k] = 'e'
            br[4*k+1] = 'f'
            br[4*k+2] = 'h'
            br[4*k+3] = 'h'
    else:
        br = ['.'] * n
        off = 4 * afour
        if (i-off) % 5 == 0:
            k = (i-off) // 5
            br[off+5*k] = 'a'
            br[off+5*k+1] = 'a'
            br[off+5*k+3] = 'b'
            br[off+5*k+4] = 'c'
        if (i-off) % 5 == 1:
            k = (i-off) // 5
            br[off+5*k+1] = 'd'
            br[off+5*k+2] = 'd'
            br[off+5*k+3] = 'b'
            br[off+5*k+4] = 'c'
        if (i-off) % 5 == 2:
            k = (i-off) // 5
            br[off+5*k] = 'a'
            br[off+5*k+2] = 'e'
            br[off+5*k+3] = 'e'
            br[off+5*k+4] = 'f'
        if (i-off) % 5 == 3:
            k = (i-off) // 5
            br[off+5*k] = 'a'
            br[off+5*k+2] = 'g'
            br[off+5*k+4] = 'f'
        if (i-off) % 5 == 4:
            k = (i-off) // 5
            br[off+5*k] = 'b'
            br[off+5*k+1] = 'b'
            br[off+5*k+2] = 'g'
            br[off+5*k+3] = 'h'
            br[off+5*k+4] = 'h'
    print(''.join( br))






Fixed submission:
n = int(input())

threeT = [
    ['a', 'a', '.'],
    ['.', '.', 'a'],
    ['.', '.', 'a']
]
fourT = [
    ['a', 'a', 'c', 'd'],
    ['b', 'b', 'c', 'd'],
    ['e', 'f', 'g', 'g'],
    ['e', 'f', 'h', 'h']
]
fiveT = [
    ['a', 'a', '.', 'c', 'd'],
    ['.', 'b', 'b', 'c', 'd'],
    ['e', '.', 'f', 'f', 'g'],
    ['e', '.', 'h', '.', 'g'],
    ['i', 'i', 'h', 'j', 'j']
]
sevenT = [
    ['a', 'a', 'b', 'b', 'c', 'c', '.'],
    ['d', 'd', 'e', 'e', '.', '.', 'f'],
    ['g', '.', '.', 'h', 'h', '.', 'f'],
    ['g', 'i', '.', '.', '.', '.', 'j'],
    ['.', 'i', '.', '.', 'k', 'k', 'j'],
    ['.', '.', 'l', '.', '.', 'm', 'n'],
    ['.', '.', 'l', '.', '.', 'm', 'n']
]

if n == 2:
    print(-1)
    exit()

if n == 7:
    for i in range(n):
        print(''.join(sevenT[i]))
    exit()

if n == 11:
    for i in range(n):
        br = ['.'] * n
        if i < 7 :
            for j in range(7):
                br[j] = sevenT[i][j]
        else:
            for j in range(4):
                br[7+j] = fourT[i-7][j]
        print(''.join(br))
    exit()

if n % 3 == 0:
    for i in range(n):
        br = ['.'] * n
        ind = i % 3
        k = i // 3
        for j in range(3):
            br[3*k+j] = threeT[ind][j]
        print(''.join(br))
    exit()
ac = n % 4
afive = ac
afour = (n - afive * 5) // 4
for i in range(n):
    br = ['.'] * n
    if i // 4 < afour:
        ind = i % 4
        k = i // 4
        for j in range(4):
            br[4*k+j] = fourT[ind][j]
    else:
        off = 4 * afour
        ind = (i-off) % 5
        k = (i-off) // 5
        for j in range(5):
            br[off+5*k+j] = fiveT[ind][j]
    print(''.join( br))

Buggy python submission (verdict: Runtime Error):
n = int(input())

if n == 2 or n == 7:
    print(-1)
    exit

if n % 3 == 0:
    for i in range(n):
        br = ['.'] * n
        if i % 3 == 0:
            k = i // 3
            br[3*k] = 'a'
            br[3*k+1] = 'a'
        else:
            k = i // 3
            br[3*k+2] = 'a'
        print(''.join( br))
    exit()
ac = n % 4
afive = ac
afour = (n - afive * ac) // 4
for i in range(n):
    if i // 4 < afour:
        br = ['.'] * n
        if i % 4 == 0:
            k = i // 4
            br[4*k] = 'a'
            br[4*k+1] = 'a'
            br[4*k+2] = 'b'
            br[4*k+3] = 'c'
        if i % 4 == 1:
            k = i // 4
            br[4*k] = 'd'
            br[4*k+1] = 'd'
            br[4*k+2] = 'b'
            br[4*k+3] = 'c'
        if i % 4 == 2:
            k = i // 4
            br[4*k] = 'e'
            br[4*k+1] = 'f'
            br[4*k+2] = 'g'
            br[4*k+3] = 'g'
        if i % 4 == 3:
            k = i // 4
            br[4*k] = 'e'
            br[4*k+1] = 'f'
            br[4*k+2] = 'h'
            br[4*k+3] = 'h'
    else:
        br = ['.'] * n
        off = 4 * afour
        if (i-off) % 5 == 0:
            k = (i-off) // 5
            br[off+5*k] = 'a'
            br[off+5*k+1] = 'a'
            br[off+5*k+3] = 'b'
            br[off+5*k+4] = 'c'
        if (i-off) % 5 == 1:
            k = (i-off) // 5
            br[off+5*k+1] = 'd'
            br[off+5*k+2] = 'd'
            br[off+5*k+3] = 'b'
            br[off+5*k+4] = 'c'
        if (i-off) % 5 == 2:
            k = (i-off) // 5
            br[off+5*k] = 'a'
            br[off+5*k+2] = 'e'
            br[off+5*k+3] = 'e'
            br[off+5*k+4] = 'f'
        if (i-off) % 5 == 3:
            k = (i-off) // 5
            br[off+5*k] = 'a'
            br[off+5*k+2] = 'g'
            br[off+5*k+4] = 'f'
        if (i-off) % 5 == 4:
            k = (i-off) // 5
            br[off+5*k] = 'b'
            br[off+5*k+1] = 'b'
            br[off+5*k+2] = 'g'
            br[off+5*k+3] = 'h'
            br[off+5*k+4] = 'h'
        print(''.join( br))






Fixed submission:
n = int(input())

threeT = [
    ['a', 'a', '.'],
    ['.', '.', 'a'],
    ['.', '.', 'a']
]
fourT = [
    ['a', 'a', 'c', 'd'],
    ['b', 'b', 'c', 'd'],
    ['e', 'f', 'g', 'g'],
    ['e', 'f', 'h', 'h']
]
fiveT = [
    ['a', 'a', '.', 'c', 'd'],
    ['.', 'b', 'b', 'c', 'd'],
    ['e', '.', 'f', 'f', 'g'],
    ['e', '.', 'h', '.', 'g'],
    ['i', 'i', 'h', 'j', 'j']
]
sevenT = [
    ['a', 'a', 'b', 'b', 'c', 'c', '.'],
    ['d', 'd', 'e', 'e', '.', '.', 'f'],
    ['g', '.', '.', 'h', 'h', '.', 'f'],
    ['g', 'i', '.', '.', '.', '.', 'j'],
    ['.', 'i', '.', '.', 'k', 'k', 'j'],
    ['.', '.', 'l', '.', '.', 'm', 'n'],
    ['.', '.', 'l', '.', '.', 'm', 'n']
]

if n == 2:
    print(-1)
    exit()

if n == 7:
    for i in range(n):
        print(''.join(sevenT[i]))
    exit()

if n == 11:
    for i in range(n):
        br = ['.'] * n
        if i < 7 :
            for j in range(7):
                br[j] = sevenT[i][j]
        else:
            for j in range(4):
                br[7+j] = fourT[i-7][j]
        print(''.join(br))
    exit()

if n % 3 == 0:
    for i in range(n):
        br = ['.'] * n
        ind = i % 3
        k = i // 3
        for j in range(3):
            br[3*k+j] = threeT[ind][j]
        print(''.join(br))
    exit()
ac = n % 4
afive = ac
afour = (n - afive * 5) // 4
for i in range(n):
    br = ['.'] * n
    if i // 4 < afour:
        ind = i % 4
        k = i // 4
        for j in range(4):
            br[4*k+j] = fourT[ind][j]
    else:
        off = 4 * afour
        ind = (i-off) % 5
        k = (i-off) // 5
        for j in range(5):
            br[off+5*k+j] = fiveT[ind][j]
    print(''.join( br))