#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n;
int t[9][9];
int win[9],lose[9];
int ans;

void f(int x,int y){
    if(x==n-1){
        bool f=true;
        rep(i,n-1)f&=win[i]==win[i+1];
        ans+=f;
        return;
    }
    int nx=x,ny=y+1;
    if(ny==n){
        nx++;
        ny=nx+1;
    }
    if(t[x][y]==-1){
        win[x]++;
        lose[y]++;
        t[x][y]=1;
        t[y][x]=0;
        if(win[x]<=n/2&&lose[y]<=n/2)f(nx,ny);
        win[x]--;
        lose[y]--;
        win[y]++;
        lose[x]++;
        t[x][y]=0;
        t[y][x]=1;
        if(win[y]<=n/2&&lose[x]<=n/2)f(nx,ny);
        win[y]--;
        lose[x]--;
        t[x][y]=-1;
        t[y][x]=-1;
    }
    else f(nx,ny);
}

void run(){
    cin>>n;
    if(!n)return;
    memset(t,-1,sizeof(t));
    MEMSET(win);
    MEMSET(lose);
    int m;
    cin>>m;
    while(m--){
        int x,y;
        cin>>x>>y;
        x--,y--;
        t[x][y]=1;
        t[y][x]=0;
        win[x]++;
        lose[y]++;
    }
    ans=0;
    f(0,1);
    cout<<ans<<endl;
    run();
}
