```
import collections
from collections import deque
class Solution:
# @param board, a 2D array
# Capture all regions by modifying the input board in-place.
# Do not return any value.
def solve(self, board):
n=len(board)
if n==0:return board
m=len(board[0])
if m==0:return board
board=[[c for c in row] for row in board]
#0 dont explored, 1 flip, 2 do not flip
state=[[False]*m for i in range(n)]
def check(v,n):
return v>=0 and v<n
def traverse(i,j,mark):
q=deque([(i,j)])
state[i][j]=True
while q:
ci,cj=q.popleft()
if mark:board[ci][cj]='X'
for mi,mj in ((-1,0),(1,0),(0,1),(0,-1)):
ni,nj=i+mi,j+mj
if check(ni,n) and check(nj,m) and not state[ni][nj] and board[ni][nj]=='O':
state[ni][nj]=True
q.append((ni,nj))
for j in range(m):
if not state[0][j] and board[0][j]=='O':traverse(0,j,0);print j
if not state[n-1][j] and board[n-1][j]=='O':traverse(n-1,j,0)
for i in range(n):
if not state[i][0] and board[i][0]=='O':traverse(i,0,0)
if not state[i][m-1] and board[i][m-1]=='O':traverse(i,m-1,0)
for i in range(n):
for j in range(m):
if not state[i][j] and board[i][j]=='O':traverse(i,j,1)
return board
```

Hello, I have a problem with my python solution. In my laptop, the code run perfectly, but when I submit the solution, I got compiler error. I don't know why. My solution is simple, I just use a BFS.