def around_check(cross,i,j):
#print i,j
if i+4 <= NUMLINESHORIZONTAL-1:
s = 0
for x in range(i,i+5):
s += cross[x][j]
if s == 5 or s == -5:
return True
if i-4 >= 0:
s = 0
for x in range(i-4,i+1):
s += cross[x][j]
if s == 5 or s == -5:
return True
if j + 4 <= NUMLINESVERTICAL-1:
s = 0
for y in range(j,j+5):
s += cross[i][y]
if s == 5 or s == -5:
return True
if j - 4 >= 0:
s = 0
for y in range(j-4,j+1):
s += cross[i][y]
if s == 5 or s == -5:
return True
if j - 4 >= 0 and i - 4 >=0:
x,y = i-4,j-4
s = 0
for z in range(5):
s += cross[x][y]
x+=1;y+=1
print "s:",s
if s == 5 or s == -5:
return True
if j + 4 <= NUMLINESVERTICAL-1 and x + 4 <= NUMLINESHORIZONTAL-1:
x,y = i,j
print "i,j",i,j
s = 0
for z in range(5):
s += cross[x][y]
x+=1;y+=1
print "s:",s
if s == 5 or s == -5:
return True
#print i,j
if i+4 <= NUMLINESHORIZONTAL-1:
s = 0
for x in range(i,i+5):
s += cross[x][j]
if s == 5 or s == -5:
return True
if i-4 >= 0:
s = 0
for x in range(i-4,i+1):
s += cross[x][j]
if s == 5 or s == -5:
return True
if j + 4 <= NUMLINESVERTICAL-1:
s = 0
for y in range(j,j+5):
s += cross[i][y]
if s == 5 or s == -5:
return True
if j - 4 >= 0:
s = 0
for y in range(j-4,j+1):
s += cross[i][y]
if s == 5 or s == -5:
return True
if j - 4 >= 0 and i - 4 >=0:
x,y = i-4,j-4
s = 0
for z in range(5):
s += cross[x][y]
x+=1;y+=1
print "s:",s
if s == 5 or s == -5:
return True
if j + 4 <= NUMLINESVERTICAL-1 and x + 4 <= NUMLINESHORIZONTAL-1:
x,y = i,j
print "i,j",i,j
s = 0
for z in range(5):
s += cross[x][y]
x+=1;y+=1
print "s:",s
if s == 5 or s == -5:
return True