#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 17;
const int maxm = 300;
const int maxk = 270000;
const ll Mod = 1e9+7;

ll pw(ll x,int k)
{
	ll re=1ll;
	for(;k;k>>=1,x=x*x%Mod) if(k&1)
		re=re*x%Mod;
	return re;
}
ll pw2[maxm];
int n,m,d[maxn];
struct edge{int y,nex;}a[maxm]; int len,fir[maxn];
inline void ins(const int x,const int y){a[++len]=(edge){y,fir[x]};fir[x]=len;}

ll f[maxk],g[maxn][maxk],g2[maxn][maxk];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		ins(x,y); d[x]++;
	}
	pw2[0]=1ll; for(int i=1;i<maxm;i++) pw2[i]=pw2[i-1]*2ll%Mod;
	
	int al=1<<n;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<al;j++)
		{
			int num=0;
			for(int k=fir[i],y=a[k].y;k;k=a[k].nex,y=a[k].y) if(j>>y-1&1) ++num;
			g[i][j]=pw2[num]-1ll;
		}
	}
	f[0]=1ll;
	for(int i=1;i<al;i++) if((i&3)==0||(i&3)==3)
	{
		for(int j=(i-1)&i;;j=(j-1)&i) if(f[j])
		{
			int oth=i-j; // sg = zero
			ll now=1ll;
			for(int k=1;k<=n;k++) if(j>>k-1&1)
				(now*=g[k][oth])%=Mod;
			for(int k=1;k<=n;k++) if(oth>>k-1&1)
				(now*=g[k][j]+1ll)%=Mod;
			(f[i]+=now*f[j]%Mod)%=Mod;
			if(!j) break;
		}
	}
	ll ans=pw2[m]-f[al-1];
	printf("%lld\n",(ans+Mod)%Mod);
	
	return 0;
}
