#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;

    vector<vector<int>> pattern;
    vector<vector<int>> table;


    void input() {
        pattern.resize(N, vector<int>(N, -1));
        table.resize(N, vector<int>(N, -1));
        int m;
        cin >> m;
        for (int i = 0; i < m; ++i) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            pattern[a][b] = 1;
            pattern[b][a] = 0;
        }
    }

    // 上からn段目を見ている
    // rec(1)が答えのつもり
    int rec(int n) {
//        cerr << n << endl;
        if (n == N) {
            // tableの数を数えておｋなら1を返す
            int win = 0, lose = 0;
            for (int i = 0; i < N; ++i) {
                if (i == n - 1) continue;
                if (table[n - 1][i]) win++;
                else lose++;
            }
            return win == lose;
        }

        int bs = N - n;
        int ret = 0;

        for (int bit = 0; bit < 1 << bs; ++bit) {
            //tableに代入
            for (int i = n; i < N; ++i) {
                table[n - 1][i] = bit >> (i - n) & 1;
                table[i][n - 1] = !(bit >> (i - n) & 1);
            }
            int win = 0, lose = 0;
            for (int i = 0; i < N; ++i) {
                if (i == n - 1) continue;
                if (table[n - 1][i]) win++;
                else lose++;
            }

            if (win != lose) continue;
            bool flag = true;
            for (int i = 0; i < N; ++i) {
                if (i == n - 1) continue;
                if (pattern[n - 1][i] == -1) continue;
                if (pattern[n - 1][i] != table[n - 1][i]) {
                    flag = false;
                    break;
                }
            }
            if (!flag) continue;

//            cerr << "bit" << bit << endl;
            ret += rec(n + 1);
        }
        return ret;
    }


    bool solve() {
        cin >> N;
        if (N == 0) return false;
        input();
        int ans = rec(1);
        cout << ans << endl;

        return true;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve()) {};


    return 0;
}



Measured memory_bytes: 3144