Code-Golf: Lights Off!
Python, 209 203 199 characters

I=input
x=I()+1
s=0
C=lambda:eval(raw_input().replace(' ','*%d+'%x))
exec's^=1&lt;&lt;C();'*I()
exec's^=1+(7&lt;&lt;x)/2+(1&lt;&lt;x&lt;&lt;x)&lt;&lt;(C()-x);'*I()
R=range(1,x)
for r in R:print''.join('OX'[s&gt;&gt;r*x+c&amp;1]for c in R)


The state of the lights is kept in a single (big) integer variable, s.  XORs with bitmasks are used to toggle the lights.  I keep an extra bit per row to prevent wraparound.