#include <iostream>

using namespace std;

int n, m, ans, table[9][9];

int chack(){
	for(int i=0; i<n; i++){
		int tmp=0;
		for(int j=0; j<n; j++) tmp += table[i][j];
		if(tmp) return 0;
	}
	return 1;
}


void dfs(int x, int y){
	if(x < n-1) x++;
	else if(y < n-1){
		x=0;
		y++;
	} else{
		ans += chack();
		return;
	}

	if(x==0 && 0<y){
		int tmp =0;
		for(int i=0; i<n; i++) tmp += table[y-1][i];
		if(tmp) return;
	}

	if(table[y][x] == 0 && y != x){
		table[y][x] = 1;
		table[x][y] = -1;
		dfs(x, y);

		table[y][x] = -1;
		table[x][y] = 1;
		dfs(x, y);

		table[y][x] = table[x][y] = 0;
	} else dfs(x, y);
}


int main(void) {
	while(1) {
		cin >> n;
		if(!n) break;
		fill(table[0], table[8], 0);
		cin >> m;
		for(int i=0; i<m; i++){
			int x, y; cin >> x >> y;
			x--; y--;
			table[x][y] = 1;
			table[y][x] = -1;
		}

		ans = 0;
		dfs(0, 0);
		cout << ans << endl;
	}
	return 0;
}
