#include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> #include<vector> #include<queue> #define MAXN 100000+10 #define MOD 1000000007 #define ll long long #define pb push_back using namespace std; int n,m,s,t; vector<int> G[MAXN]; int de[MAXN],De[MAXN]; ll inv[MAXN<<1],f[MAXN],ans=1; void init(){ scanf("%d%d%d%d",&n,&m,&s,&t); for(int i=1;i<=m;i++){ int x,y;scanf("%d%d",&x,&y); G[x].pb(y); de[y]++,De[y]++; } De[t]++; int i; for(inv[1]=1,i=2;i<=m;i++){ inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD; } for(i=2;i<=n;i++){ (ans*=De[i])%=MOD; } f[t]=ans; } void TopoSort(){ queue<int> q; for(int i=1;i<=n;i++){ if(!de[i])q.push(i); } while(!q.empty()){ int x=q.front();q.pop(); (f[x]*=inv[De[x]])%=MOD; for(int i=0;i<G[x].size();i++){ int y=G[x][i]; (f[y]+=f[x])%=MOD; if(!(--de[y])){ q.push(y); } } } } void solve(){ if(t==1){ printf("%lld",ans); return; } TopoSort(); printf("%lld",(ans-f[s]+MOD)%MOD); } int main() { // freopen("data.in","r",stdin); init(); solve(); return 0; }