def pacific_atlantic(matrix):
n = len(matrix)<EOL>if not n: return []<EOL>m = len(matrix[<NUM_LIT:0>])<EOL>if not m: return []<EOL>res = []<EOL>atlantic = [[False for _ in range (n)] for _ in range(m)]<EOL>pacific =  [[False for _ in range (n)] for _ in range(m)]<EOL>for i in range(n):<EOL><INDENT>dfs(pacific, matrix, float("<STR_LIT>"), i, <NUM_LIT:0>)<EOL>dfs(atlantic, matrix, float("<STR_LIT>"), i, m-<NUM_LIT:1>)<EOL><DEDENT>for i in range(m):<EOL><INDENT>dfs(pacific, matrix, float("<STR_LIT>"), <NUM_LIT:0>, i)<EOL>dfs(atlantic, matrix, float("<STR_LIT>"), n-<NUM_LIT:1>, i)<EOL><DEDENT>for i in range(n):<EOL><INDENT>for j in range(m):<EOL><INDENT>if pacific[i][j] and atlantic[i][j]:<EOL><INDENT>res.append([i, j])<EOL><DEDENT><DEDENT><DEDENT>return res<EOL>
:type matrix: List[List[int]]
:rtype: List[List[int]]