num_route = 0

num_node = 0



def func(unvisited_paths, visited_node, current_node):

    global num_route

    if len(visited_node) == num_node:

            num_route += 1

            return

    for next_path in [path for path in unvisited_paths if (path[0] == current_node) and (path[1] not in visited_node)]:

        next_visited_node = visited_node + [next_path[1]]

        next_unvisited_paths = unvisited_paths[:]

        next_unvisited_paths.pop(next_unvisited_paths.index([current_node, next_path[1]]))

        next_unvisited_paths.pop(next_unvisited_paths.index([next_path[1], current_node]))

        next_current_node = next_path[1]

        

        func(next_unvisited_paths, next_visited_node, next_current_node)

    

    return



def main():

    global num_node

    num_node, num_path = list(map(int, input().split()))

    unvisited_paths = [list(map(int, input().split())) for i in range(num_path)]

    for path in unvisited_paths[:]:

        unvisited_paths.append([path[1], path[0]])

    current_node, visited_node = 1, [1]

    func(unvisited_paths, visited_node, current_node)

    print(num_route)



if __name__ == '__main__':

    main()
import sys

readline = sys.stdin.readline

from collections import deque



def main():

    N, M = list(map(int, readline().rstrip().split()))

    path = [[False] * N for _ in range(N)]

    for _ in range(M):

        a, b = list(map(int, readline().rstrip().split()))

        path[a-1][b-1] = True

        path[b-1][a-1] = True

    

    que = deque([[0]])  # 訪れた順にノードを格納

    cnt = 0

    while que:

        visited = que.popleft()

        if len(visited) == N:

            cnt += 1

            continue

        pre = visited[-1]

        for next in range(N):

            if next not in visited and path[pre][next]:

                que.append(visited+[next])

            

    print(cnt)



if __name__ == '__main__':

    main()
num_route = 0
num_node = 0


def func(unvisited_paths, visited_node, current_node):
    global num_route
    if len(visited_node) == num_node:
        num_route += 1
        return
    for next_path in [
        path
        for path in unvisited_paths
        if (path[0] == current_node) and (path[1] not in visited_node)
    ]:
        next_visited_node = visited_node + [next_path[1]]
        next_unvisited_paths = unvisited_paths[:]
        next_unvisited_paths.pop(
            next_unvisited_paths.index([current_node, next_path[1]])
        )
        next_unvisited_paths.pop(
            next_unvisited_paths.index([next_path[1], current_node])
        )
        next_current_node = next_path[1]
        func(next_unvisited_paths, next_visited_node, next_current_node)
    return


def main():
    global num_node
    num_node, num_path = list(map(int, input().split()))
    unvisited_paths = [list(map(int, input().split())) for i in range(num_path)]
    for path in unvisited_paths[:]:
        unvisited_paths.append([path[1], path[0]])
    current_node, visited_node = 1, [1]
    func(unvisited_paths, visited_node, current_node)
    print(num_route)


if __name__ == "__main__":
    main()

import sys

readline = sys.stdin.readline
from collections import deque


def main():
    N, M = list(map(int, readline().rstrip().split()))
    path = [[False] * N for _ in range(N)]
    for _ in range(M):
        a, b = list(map(int, readline().rstrip().split()))
        path[a - 1][b - 1] = True
        path[b - 1][a - 1] = True
    que = deque([[0]])  # 訪れた順にノードを格納
    cnt = 0
    while que:
        visited = que.popleft()
        if len(visited) == N:
            cnt += 1
            continue
        pre = visited[-1]
        for next in range(N):
            if next not in visited and path[pre][next]:
                que.append(visited + [next])
    print(cnt)


if __name__ == "__main__":
    main()

-num_route = 0 -num_node = 0 +import sys - -def func(unvisited_paths, visited_node, current_node): -    global num_route -    if len(visited_node) == num_node: -        num_route += 1 -        return -    for next_path in [ -        path -        for path in unvisited_paths -        if (path[0] == current_node) and (path[1] not in visited_node) -    ]: -        next_visited_node = visited_node + [next_path[1]] -        next_unvisited_paths = unvisited_paths[:] -        next_unvisited_paths.pop( -            next_unvisited_paths.index([current_node, next_path[1]]) -        ) -        next_unvisited_paths.pop( -            next_unvisited_paths.index([next_path[1], current_node]) -        ) -        next_current_node = next_path[1] -        func(next_unvisited_paths, next_visited_node, next_current_node) -    return +readline = sys.stdin.readline +from collections import deque -    global num_node -    num_node, num_path = list(map(int, input().split())) -    unvisited_paths = [list(map(int, input().split())) for i in range(num_path)] -    for path in unvisited_paths[:]: -        unvisited_paths.append([path[1], path[0]]) -    current_node, visited_node = 1, [1] -    func(unvisited_paths, visited_node, current_node) -    print(num_route) +    N, M = list(map(int, readline().rstrip().split())) +    path = [[False] * N for _ in range(N)] +    for _ in range(M): +        a, b = list(map(int, readline().rstrip().split())) +        path[a - 1][b - 1] = True +        path[b - 1][a - 1] = True +    que = deque([[0]])  # 訪れた順にノードを格納 +    cnt = 0 +    while que: +        visited = que.popleft() +        if len(visited) == N: +            cnt += 1 +            continue +        pre = visited[-1] +        for next in range(N): +            if next not in visited and path[pre][next]: +                que.append(visited + [next]) +    print(cnt)