#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

void func(vector<vector<int>>&win, vector<int>&sum, int a, int b) {
	//cout << "a b " << a << " " << b << endl;
	//cout << sum[a] << endl;
	if (a == N - 1) {
		//for (auto i : sum)cout << i << endl;
		//cout << endl;
		if (!sum[a])K++;
		return;
	}
	if (win[a][b] >= 0) {
		int bef = win[a][b];
		win[a][b] = 1, win[b][a] = -1;
		sum[a]++;
		sum[b]--;
		if (b == N - 1) {
			if (!sum[a]) {
				func(win, sum, a + 1, a + 2);
			}
			win[a][b] = bef, win[b][a] = -bef;
			sum[a]--;
			sum[b]++;
		}
		else {
			func(win, sum, a, b + 1);
			win[a][b] = bef, win[b][a] = -bef;
			sum[a]--;
			sum[b]++;
		}
	}
	if (win[a][b] <= 0) {
		int bef = win[a][b];
		win[a][b] = -1, win[b][a] = 1;
		sum[a]--;
		sum[b]++;
		if (b == N - 1) {
			if (!sum[a]) {
				func(win, sum, a + 1, a + 2);
			}
			win[a][b] = bef, win[b][a] = -bef;
			sum[a]++;
			sum[b]--;
		}
		else {
			func(win, sum, a, b + 1);
			win[a][b] = bef, win[b][a] = -bef;
			sum[a]++;
			sum[b]--;
		}
	}
	return;
}

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

	while (cin >> N, N) {
		K = 0;
		cin >> M;
		vector<vector<int>>win(N, vector<int>(N));
		vector<int>sum(N);
		for (int i = 0; i < M; i++) {
			cin >> L >> R;
			L--, R--;
			win[L][R] = 1;
			win[R][L] = -1;
		}
		func(win, sum, 0, 1);
		cout << K << endl;
	}
}
