#P5241. Essentially Different Edge Sequences

    ID: 18477 Type: Default 1000ms 256MiB

Essentially Different Edge Sequences

Essentially Different Edge Sequences

You are given two integers, $N$ and $E$. Consider a directed graph $G$ with $N$ vertices (numbered from 1 to $N$) and initially no edges. A sequence $A$ of $E$ distinct directed edges is chosen from all possible edges; each edge is of the form $(s,t)$ with $1 \le s,t \le N$ and $s \neq t$. The edges in $A$ are then added to $G$ one by one in the given order.

After each addition, you compute the number of strongly connected components (SCCs) in the current graph and record it into a sequence $B$ of length $E$. Two edge sequences are said to be essentially equivalent if they produce the same sequence $B$.

Your task is to count the number of essentially different edge sequences, i.e. the number of distinct sequences $B$ that may appear. Since the answer can be large, output it modulo $10^9+7$.

Note: In this problem the input constraints are small (for example, you may assume $N\le 3$ and $E\le N(N-1)$), so a brute force solution that generates all valid edge sequences is acceptable.

inputFormat

The first line contains two integers $N$ and $E$, where $N$ is the number of vertices and $E$ is the number of edges to be added to the graph.

outputFormat

Output a single integer: the number of essentially different edge sequences (i.e. distinct $B$ sequences) modulo $10^9+7$.

sample

2 1
1