This time the Grand Circus of Byteland has invited a magician to showcase his magic to the audience. This magician, as others, boasts to have a puzzle that no one can possibly crack. Whoever solves the puzzle, asked by the magician, is promised a huge prize by the Circus.
The Magician has N cups with each cup having a ball within it. Initially, balls are placed in the cups in increasing order of their ids i.e 1, 2, ... N. The magician can make zero or more swaps among a pair of cups. However there are only certain allowed swaps i.e. cups with only certain position a and b can be swapped. And one such allowed swap can be performed any no of times including 0. After one swap ‘a’ ‘b’, the two cups at positions ‘a’ and ‘b’ respectively swaps their position along with the balls within them. The magician tells his allowed swaps to the audience and asks how many distinct arrangement of the balls are possible after performing a finite no of allowed swappings of these cups. Adam, being a coder, got amazed by the puzzle and want to win the grand prize of this event. He tried to crack it but his attempts were in vain. So he asks you to solve the problem. Can you help Adam ???
Input:
The input consist of a integer N and M which denotes the no of Cups and the allowed swaps respectively. The following lines consist of M pair ‘a’, ‘b’ (1 based, quotes only for clarity) that represents that it is possible to make a swap between the the cups at position a and b.
Ouput:
Answer the no of distinct arrangements the balls after finite swaps of these cups. Since the answer can be too large print it modulo 10^9 + 7
Constraints:
1 <= N <= 10000
1 <= M <= 100000
The pair(a, b) can be of form a = b
Problem Setter: Swapnil Saxena