class Graph:

    def __init__(self):

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



        self.adj = [[] for _ in range(n)]

        for _ in range(m):

            a, b = list(map(int, input().split()))

            a -= 1

            b -= 1

            self.adj[a].append(b)

            self.adj[b].append(a)



        self.cnt = 0

        self.depth = 0

        self.ds = [-1] * n



    def solve(self, u):

        self.ds[u] = self.depth

        if self.ds.count(-1) == 0:

            self.cnt += 1

            return



        self.depth += 1

        for v in self.adj[u]:

            if self.ds[v] == -1:

                self.solve(v)

                self.ds[v] = -1

        self.depth -= 1





def main():

    graph = Graph()

    graph.solve(0)

    print((graph.cnt))





if __name__ == "__main__":

    main()

from itertools import permutations



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

ab = [list(map(int, input().split())) for _ in range(m)]



g = [[0] * n for _ in range(n)]

for a, b in ab:

    a -= 1

    b -= 1

    g[a][b] = 1

    g[b][a] = 1



ans = 0

for pat in permutations(list(range(1, n)), n - 1):

    is_path = True

    u = 0

    for v in pat:

        if g[u][v] == 0:

            is_path = False

        u = v



    if is_path:

        ans += 1



print(ans)

class Graph:
    def __init__(self):
        n, m = list(map(int, input().split()))
        self.adj = [[] for _ in range(n)]
        for _ in range(m):
            a, b = list(map(int, input().split()))
            a -= 1
            b -= 1
            self.adj[a].append(b)
            self.adj[b].append(a)
        self.cnt = 0
        self.depth = 0
        self.ds = [-1] * n

    def solve(self, u):
        self.ds[u] = self.depth
        if self.ds.count(-1) == 0:
            self.cnt += 1
            return
        self.depth += 1
        for v in self.adj[u]:
            if self.ds[v] == -1:
                self.solve(v)
                self.ds[v] = -1
        self.depth -= 1


def main():
    graph = Graph()
    graph.solve(0)
    print((graph.cnt))


if __name__ == "__main__":
    main()

from itertools import permutations

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
g = [[0] * n for _ in range(n)]
for a, b in ab:
    a -= 1
    b -= 1
    g[a][b] = 1
    g[b][a] = 1
ans = 0
for pat in permutations(list(range(1, n)), n - 1):
    is_path = True
    u = 0
    for v in pat:
        if g[u][v] == 0:
            is_path = False
        u = v
    if is_path:
        ans += 1
print(ans)

-class Graph: -    def __init__(self): -        n, m = list(map(int, input().split())) -        self.adj = [[] for _ in range(n)] -        for _ in range(m): -            a, b = list(map(int, input().split())) -            a -= 1 -            b -= 1 -            self.adj[a].append(b) -            self.adj[b].append(a) -        self.cnt = 0 -        self.depth = 0 -        self.ds = [-1] * n +from itertools import permutations -    def solve(self, u): -        self.ds[u] = self.depth -        if self.ds.count(-1) == 0: -            self.cnt += 1 -            return -        self.depth += 1 -        for v in self.adj[u]: -            if self.ds[v] == -1: -                self.solve(v) -                self.ds[v] = -1 -        self.depth -= 1 - - -def main(): -    graph = Graph() -    graph.solve(0) -    print((graph.cnt)) - - -if __name__ == "__main__": -    main() +n, m = list(map(int, input().split())) +ab = [list(map(int, input().split())) for _ in range(m)] +g = [[0] * n for _ in range(n)] +for a, b in ab: +    a -= 1 +    b -= 1 +    g[a][b] = 1 +    g[b][a] = 1 +ans = 0 +for pat in permutations(list(range(1, n)), n - 1): +    is_path = True +    u = 0 +    for v in pat: +        if g[u][v] == 0: +            is_path = False +        u = v +    if is_path: +        ans += 1 +print(ans)