AlgoUniversity
  • Go Back
Discussion
Employees Dilemma :

Author

Ayush Gangwani

Difficulty Level : Medium

Submissions : 379

Asked In : CapitalOne

Marks :15

: 12 | : 0

There are $$$N$$$ employees and $$$N$$$ chairs. You are given $$$M$$$ pair of integers $$$(X,Y)$$$ where $$$(X,Y)$$$ denotes that employee $$$X$$$ cannot sit on seat $$$Y$$$. You have to tell number of arrangements of $$$N$$$ employees on $$$N$$$ chairs such that all constraints satisfy.

Input

The first line of input contains two space separated integers $$$N$$$ $$$(1 \le N \le 20)$$$ and $$$M$$$ $$$(0 \le M \le 100)$$$ — the number of employees (and the number of chairs) and the number of restrictions respectively.

The next $$$M$$$ lines contain two space separated integers $$$X$$$ and $$$Y$$$ $$$(1 \le X,Y \le N)$$$ each denoting that employee $$$X$$$ cannot sit on seat $$$Y$$$.

Output

Print a single integer — the number of arrangements of the employees on the chairs such that all constraints satisfy.

Examples

Input
3 1
2 2
Output
4
Input
20 0
Output
2432902008176640000

Note

In sample test case 1, the possible arrangements are $$${[2,1,3], [1,3,2], [3,1,2], [2,3,1]}$$$.

In sample test case 2, there are no restrictions. Hence there are $$$20!$$$ arrangements possible.

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.