Buggy python submission (verdict: Runtime Error):
import itertools

n,m = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(m)]
ab = [[False]*n for _ in range(n)] 
for i in range(n):
  ab[AB[i][0]-1][AB[i][1]-1] = 1
  ab[AB[i][1]-1][AB[i][0]-1] = 1

ans = 0
for que in itertools.permutations(range(n), n):
  if que[0] == 0:
    for k in range(n):
      if k == n-1:
        ans += 1
      else:
        if ab[que[k]][que[k+1]] != 1:
          break
      

print(ans)

Fixed submission:
import itertools
n,m = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(m)]
a = [0]*n
for x,y in A:
  a[x-1] |= 1<<(y-1)
  a[y-1] |= 1<<(x-1)

def bitdp(n, a):
  dp = [[0]*n for _ in range(1<<n)]
  dp[1][0] = 1
  
  for bit in range(1<<n):
    for v in range(n):
      if bit & 1<<v:
        sub = bit ^ (1<<v)
        
        for u in range(n):
          if (sub & 1<<u) and (a[v] & 1<<u):
            dp[bit][v] += dp[sub][u]
  ans = sum(dp[(1<<n)-1][u] for u in range(1,n))
  return ans

ans = bitdp(n,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
import itertools

n,m = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(m)]
ab = [[False]*n for _ in range(n)] 
for i in range(n):
  ab[AB[i][0]-1][AB[i][1]-1] = 1
  ab[AB[i][1]-1][AB[i][0]-1] = 1

ans = 0
for i in itertools.permutations(range(n), n):
  if i[0] == 0:
    que = i
    cnt = 1
    for k in range(n-1):
      if ab[que[k]][que[k+1]] == 1:
        cnt += 1
    if cnt == n:
      ans += 1

print(ans)

Fixed submission:
import itertools
n,m = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(m)]
a = [0]*n
for x,y in A:
  a[x-1] |= 1<<(y-1)
  a[y-1] |= 1<<(x-1)

def bitdp(n, a):
  dp = [[0]*n for _ in range(1<<n)]
  dp[1][0] = 1
  
  for bit in range(1<<n):
    for v in range(n):
      if bit & 1<<v:
        sub = bit ^ (1<<v)
        
        for u in range(n):
          if (sub & 1<<u) and (a[v] & 1<<u):
            dp[bit][v] += dp[sub][u]
  ans = sum(dp[(1<<n)-1][u] for u in range(1,n))
  return ans

ans = bitdp(n,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
import itertools

n,m = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(m)]
ab = [[] for _ in range(n)] 
for i in range(n):
  ab[AB[i][0]-1].append(AB[i][1]-1)
  ab[AB[i][1]-1].append(AB[i][0]-1)

ans = 0
for i in itertools.permutations(range(n), n):
  if i[0] == 0:
    que = i
    cnt = 1
    for k in range(n-1):
      if que[k+1] in ab[que[k]]:
        cnt += 1
    if cnt == n:
      ans += 1

print(ans)

Fixed submission:
import itertools
n,m = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(m)]
a = [0]*n
for x,y in A:
  a[x-1] |= 1<<(y-1)
  a[y-1] |= 1<<(x-1)

def bitdp(n, a):
  dp = [[0]*n for _ in range(1<<n)]
  dp[1][0] = 1
  
  for bit in range(1<<n):
    for v in range(n):
      if bit & 1<<v:
        sub = bit ^ (1<<v)
        
        for u in range(n):
          if (sub & 1<<u) and (a[v] & 1<<u):
            dp[bit][v] += dp[sub][u]
  ans = sum(dp[(1<<n)-1][u] for u in range(1,n))
  return ans

ans = bitdp(n,a)
print(ans)