#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, match[10][10];

int solve(int x, int y)
{
    if (x == n - 1 && y == n - 1)
        return 1;
    int nx = x, ny = y + 1;
    if (ny == n)
        nx++, ny = 0;
    if (match[x][y] != 0)
        return solve(nx, ny);
    int xwin = 0, xlose = 0, ywin = 0, ylose = 0;
    rep(i, n)
    {
        if (match[x][i] == 1)
            xwin++;
        if (match[x][i] == -1)
            xlose++;
    }
    rep(i, n)
    {
        if (match[y][i] == 1)
            ywin++;
        if (match[y][i] == -1)
            ylose++;
    }
    int res = 0;
    if (xwin < n / 2 && ylose < n / 2)
    {
        match[x][y] = 1, match[y][x] = -1;
        res += solve(nx, ny);
        match[x][y] = match[y][x] = 0;
    }
    if (xlose < n / 2 && ywin < n / 2)
    {
        match[x][y] = -1, match[y][x] = 1;
        res += solve(nx, ny);
        match[x][y] = match[y][x] = 0;
    }
    return res;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    while (cin >> n, n)
    {
        rep(i, n) rep(j, n) match[i][j] = 0;
        rep(i, n) match[i][i] = 2;
        int m;
        cin >> m;
        rep(i, m)
        {
            int x, y;
            cin >> x >> y;
            x--, y--;
            match[x][y] = 1;
            match[y][x] = -1;
        }
        bool ok = true;
        rep(i, n)
        {
            int win = 0, lose = 0;
            rep(j, n)
            {
                if (match[i][j] == 1)
                    win++;
                if (match[i][j] == -1)
                    lose++;
            }
            if (win > n / 2 || lose > n / 2)
                ok = false;
        }
        cout << (ok ? solve(0, 0) : 0) << endl;
    }
}
