SOLVE

LATER

Micro and Permutations

Problem

Editorial

Analytics

Micro is having a graph having *N* vertices numbered from *1* to *N* and *M* edges. All the edges are bidirectional. Micro wants to find out the number of lucky permutations in the graph.

A permutation of the vertices \([v_1, v_2, v_3,...., v_n ]\) is called lucky permutation, if for every vertex \(v_i \), where \(1 \le i \le N-1\), there is an edge between \(v_i\) and \(v_{i+1}\).
Help Micro find out the number of lucky permutations in the graph.

**Input:**

First line consists of two space separated integers denoting *N* and *M*.

*M* lines follow each consisting of two space separated integers *X* and *Y* denoting there is an edge between vertices numbered *X* and *Y*.

**Output:**

Print the number of lucky permutations in the graph.

**Constraints:**

\(1 \le N \le 10\)

\(1 \le M \le 100\)

\(1 \le X, Y \le N\)

Explanation

The two possible lucky permutations are 1-2-3 and 3-2-1.

Time Limit:
5.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
Bash,
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Swift-4.1,
TypeScript,
Visual Basic

Initializing Code Editor...

{"2da40b6": "/pagelets/problem-author-tester/algorithm/micro-and-permutations/", "cd52253": "/pagelets/suggested-problems/algorithm/micro-and-permutations/", "789ff90": "/pagelets/recommended-problems/algorithm/micro-and-permutations/", "f67270b": "/pagelets/problems-hint/algorithm/micro-and-permutations/", "75ec455": "/pagelets/show-submission/algorithm/micro-and-permutations/"}

realtime.hackerearth.com

80

63bd0c66d95c379355387d579abe876fa99e7097

58a29e5cae2309f04b28

/realtime/pusher/auth/