#include <cstdio>
#define MOD 1000000007
typedef long long ll;
int cnt[25][100005], dp[100005];
int main()
{
	// freopen("AGC016-F.in", "r", stdin);
	int n, m, ans = 1;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		cnt[--u][1 << --v]++;
		(ans += ans) %= MOD;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 1 << n; j++)
			cnt[i][j] = cnt[i][j & -j] + cnt[i][j ^ (j & -j)];
	}
	for (int i = 0; i < 1 << n; i++)
	{
		if ((i & 3) && (i & 3) != 3)
			continue;
		dp[i] = 1;
		for (int j = i - 1 & i; j; j = j - 1 & i)
		{
			if ((j & 3) && (j & 3) != 3)
				continue;
			int x = i ^ j, val = dp[x];
			for (int k = 0; k < n; k++)
			{
				if (x & (1 << k))
					val = (ll)val * ((1 << cnt[k][j]) - 1) % MOD;
				else if (j & (1 << k))
					val = (ll)val * (1 << cnt[k][x]) % MOD;
			}
			(dp[i] += val) %= MOD;
		}
	}
	printf("%d\n", (ans - dp[(1 << n) - 1] + MOD) % MOD);
	return 0;
}
