import sys

input = sys.stdin.readline

from operator import itemgetter



lis = []

n = 0

m = 0

ans = 0

visited = []



def dfs(i, d, fr):

    global lis, ans, visited

    if visited[i] == 1:

        return

    if d == n - 1:

        ans += 1

        return

    for j in lis[i]:

        if j != fr:

            visited[i] = 1

            # print(i+1 , j+1)

            dfs(j, d+1, i)

            visited[i] = -1





def main():

    global lis, n, m, ans, visited

    n, m = list(map(int, input().strip().split()))

    lis = [[] for _ in range(n)]

    visited = [-1] * n

    for _ in range(m):

        a, b = list([x-1 for x in list(map(int, input().strip().split()))])

        lis[a].append(b)

        lis[b].append(a)

    # print("##")

    dfs(0, 0, -1)

    print(ans)



if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline

from operator import itemgetter

import itertools



def main():

    n, m = list(map(int, input().strip().split()))

    lis = [[] for _ in range(n)]

    visited = [-1] * n

    for _ in range(m):

        a, b = list([x-1 for x in list(map(int, input().strip().split()))])

        lis[a].append(b)

        lis[b].append(a)

    

    ans = 0

    for path in itertools.permutations(list(range(n)), n):

        if path[0] != 0:

            continue

        c = True

        for i in range(n-1):

            pi1 = path[i+1]

            pi = path[i]

            # print(path)

            if pi1 not in lis[pi]:

                c = False

                break

        if c:

            ans += 1

    print(ans)



if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline
from operator import itemgetter

lis = []
n = 0
m = 0
ans = 0
visited = []


def dfs(i, d, fr):
    global lis, ans, visited
    if visited[i] == 1:
        return
    if d == n - 1:
        ans += 1
        return
    for j in lis[i]:
        if j != fr:
            visited[i] = 1
            # print(i+1 , j+1)
            dfs(j, d + 1, i)
            visited[i] = -1


def main():
    global lis, n, m, ans, visited
    n, m = list(map(int, input().strip().split()))
    lis = [[] for _ in range(n)]
    visited = [-1] * n
    for _ in range(m):
        a, b = list([x - 1 for x in list(map(int, input().strip().split()))])
        lis[a].append(b)
        lis[b].append(a)
    # print("##")
    dfs(0, 0, -1)
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
from operator import itemgetter
import itertools


def main():
    n, m = list(map(int, input().strip().split()))
    lis = [[] for _ in range(n)]
    visited = [-1] * n
    for _ in range(m):
        a, b = list([x - 1 for x in list(map(int, input().strip().split()))])
        lis[a].append(b)
        lis[b].append(a)
    ans = 0
    for path in itertools.permutations(list(range(n)), n):
        if path[0] != 0:
            continue
        c = True
        for i in range(n - 1):
            pi1 = path[i + 1]
            pi = path[i]
            # print(path)
            if pi1 not in lis[pi]:
                c = False
                break
        if c:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

- -lis = [] -n = 0 -m = 0 -ans = 0 -visited = [] - - -def dfs(i, d, fr): -    global lis, ans, visited -    if visited[i] == 1: -        return -    if d == n - 1: -        ans += 1 -        return -    for j in lis[i]: -        if j != fr: -            visited[i] = 1 -            # print(i+1 , j+1) -            dfs(j, d + 1, i) -            visited[i] = -1 +import itertools -    global lis, n, m, ans, visited -    # print("##") -    dfs(0, 0, -1) +    ans = 0 +    for path in itertools.permutations(list(range(n)), n): +        if path[0] != 0: +            continue +        c = True +        for i in range(n - 1): +            pi1 = path[i + 1] +            pi = path[i] +            # print(path) +            if pi1 not in lis[pi]: +                c = False +                break +        if c: +            ans += 1