I get TLE in "Last executed input: 7"

```
class Solution:
n = 0
def __init__(self):
self.n = 0
def dfs(self, step, h, x1, x2):
if step == 0:
return 1
k = h | x1 | x2
ans = 0
for i in xrange(self.n):
if (k & (1 << i)) == 0:
ans += self.dfs(step - 1, h | k, (x1 | k) >> 1, (x2 | k) << 1)
return ans
# @return an integer
def totalNQueens(self, n):
self.n = n
return self.dfs(n, 0, 0, 0)
```