w, h = 500, 500 print "P3" print w, h print 255 for x in xrange(500): for y in xrange(500): print x % 255, y % 255, 0, # note the comma, this doesn't produce a new line character