#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int N;
long long dp[1010][10][5][5], edp[1010][10][5][5];      // i番目, j人, 前回, 1人目

int main() {
    memset(dp, 0, sizeof(dp));
    memset(edp, 0, sizeof(edp));
    dp[1][0][0][0] = 1; dp[1][1][1][1] = 1;
    edp[1][0][0][0] = 1; edp[1][1][1][1] = 1; edp[1][1][2][2] = 1;
    for (int i = 1; i < 100; ++i) {
        for (int j = 0; j <= 8; ++j) {
            for (int k = 0; k < 2; ++k) {
                //cout << i << ", " << j << ", " << k << " : " << dp[i][j][0][k] << ", " << dp[i][j][1][k] << ", " << endl;
                dp[i+1][j][0][k] += dp[i][j][0][k];
                dp[i+1][j][0][k] += dp[i][j][1][k];
                dp[i+1][j+1][1][k] += dp[i][j][0][k];
            }
            for (int k = 0; k < 3; ++k) {
                //cout << i << ", " << j << ", " << k << " : " << edp[i][j][0][k] << ", " << edp[i][j][1][k] << ", " << edp[i][j][2][k] << endl;
                edp[i+1][j][0][k] += edp[i][j][0][k];
                edp[i+1][j][0][k] += edp[i][j][1][k];
                edp[i+1][j][0][k] += edp[i][j][2][k];
                edp[i+1][j+1][1][k] += edp[i][j][0][k];
                edp[i+1][j+1][1][k] += edp[i][j][2][k];
                edp[i+1][j+1][2][k] += edp[i][j][0][k];
                edp[i+1][j+1][2][k] += edp[i][j][1][k];
            }
        }
    }
    while (cin >> N) {
        if (N == 0) break;
        long long res = 0;
        if (N & 1) {
            res = dp[N][8][0][0] + dp[N][8][0][1] + dp[N][8][1][0];
        }
        else {
            res = edp[N/2][8][0][0] + edp[N/2][8][0][1] + edp[N/2][8][0][2] 
            + edp[N/2][8][1][0] + edp[N/2][8][1][1] + edp[N/2][8][2][0] + edp[N/2][8][2][2];
        }
        cout << res * 40320 << endl;
    }
    return 0;
}


Measured memory_bytes: 5112