#!/usr/bin/python
import sys
import Image

def to_color(s):
    t = (s[0:2], s[2:4], s[4:6])
    return tuple(map(lambda x: int(x, 16), t))

if __name__ == '__main__':
    n = int(sys.argv[1])
    ifilename = sys.argv[2]
    ofilename = sys.argv[3]

    import Image
    im = Image.open(ifilename)
    (w, h) = im.size #(1001, 1001)

    for row in xrange(0, h):
        for col in xrange(0, w):
            if (row == (h-1)/2) or (col == (w-1)/2):
                im.putpixel((col, row), to_color("000000"))
            elif (row % n == 0) or (col % n == 0):
                im.putpixel((col, row), to_color("999999"))

    im.save(ofilename)
