#define N 10
void traverse(bool edge[N][N], int m, int n, int cur, int end, int &result) {
if (!m && end == cur) {
result++;
return;
} else if (!m && end != cur) {
return;
} else {
for (int i = 0; i < n; ++i) {
if (edge[cur][i]) {
m--;
traverse(edge, m, n, i, end, result);
m++;
}
}
}
}
int getTraverseWays() {
int m; //经过城市数
int n; //城市总数
bool edge[N][N]; //城市间是否连接
input(m, n, edge);
// printMatrix(edge, n, n);
int ways = 0; //满足的道路条数
traverse(edge, m, n, 0, n - 1, ways);
return ways;
}