#include
using namespace std;
struct edge { int t; edge* next; };
typedef long long dint; #define _l (long long int)
const int maxn = 100009; const int maxe = 200009; const int mod = 1e9 + 7;
int n, m, x, y, ans, ind[maxn], tpo[maxn], tpn[maxn], inv[maxn], f[maxn]; edge ebuf_arr[maxe], *ebuf(ebuf_arr), *head[maxn];
int modPow(int a, int x) { int s(1); for (; x; x »= 1, a = _l a * a % mod) if (x & 1) s = _l s * a % mod; return s; }
inline void addEdge(int u, int v) { ebuf-> t = v; ebuf-> next = head[u]; head[u] = ebuf ++; }
int topSort(int* q) { static int c[maxn]; int hd(0), tl(1); for (int i = 1; i <= n; ++ i) c[i] = ind[i]; q[hd] = 1; while (hd < tl) { int p(q[hd ++]); for (edge* e = head[p]; e; e = e-> next) { – c[e-> t]; if (!c[e-> t]) q[tl ++] = e-> t; } } return tl; }
#define mInc(a,b) {
a += b;
if (a >= mod)
a -= mod;
}
int DP() { int nt(1); for (int i = 1; i <= n; ++ i) inv[i] = modPow(i, mod - 2); for (int i = 2; i <= n; ++ i) nt = _l nt * ind[i] % mod; memset(f, 0, sizeof(f)); for (int i = 0; i < n; ++ i) tpn[tpo[i]] = i; – ind[y]; f[y] = _l ans * inv[ind[y]] % mod; for (int i = tpn[y]; i < tpn[x]; ++ i) { int p(tpo[i]); for (edge* e = head[p]; e; e = e-> next) mInc(f[e-> t], _l f[p] * inv[ind[e-> t]] % mod); } return (nt - f[x] + mod) % mod; }
int main() { #ifndef ONLINE_JUDGE freopen(".in", “r”, stdin); #endif
scanf("%d%d%d%d", &n, &m, &x, &y);
memset(head, 0, sizeof(head));
memset(ind, 0, sizeof(ind));
for (int i = 0; i < m; ++ i) {
int u, v;
scanf("%d%d", &u, &v);
addEdge(u, v);
++ ind[v];
}
ans = 1;
for (int i = 2; i <= n; ++ i)
ans = _l ans * ind[i] % mod;
topSort(tpo);
if (x != y) {
addEdge(x, y);
++ ind[y];
}
if (topSort(tpn) < n && x != y && y != 1) {
ans = DP();
}
else {
ans = 1;
for (int i = 2; i <= n; ++ i)
ans = _l ans * ind[i] % mod;
}
printf("%d\n", ans);
}