#include <stdio.h>
long long f[1048577];
int a[21];
inline int lowbit(int x){return x & (-x);}
int main()
{
freopen("examone.in", "r", stdin);
freopen("examone.out", "w", stdout);
int n, m, x, y, c, R, i, t;
scanf("%d%d", &n, &m);
for (i = 0; i < m; i++)
{
scanf("%d%d", &x, &y);
a[x] ^= 1<<(y-1);
}
R = 1<<n; f[0] = 1;
for (i = 1; i < R; i++)
{
for (c = 0, t = i; t; ) c++, t -= lowbit(t);
for (t = i&(~a[c]); t; ) f[i] += f[i^lowbit(t)], t -= lowbit(t);
}
printf("%lld", f[R-1]);
return 0;
}