text: size() == 0 && Len + 1 + o <= 2 * n) add(f_After[k][B][Len + 1 + o], tmp[A][l][o]); } else return; } return; } int tot = 0, First; void Dp1(int f[MAX][MAX][MAX], int after[MAX][MAX]) { int i, j, k, l, o; memset(tmp, 0, sizeof tmp); for ((i) = (1); (i) <= (n); ++(i)) tmp[i][i][0] = 1; int up = 2 * n; for ((l) = (1); (l) <= (up); ++(l)) for ((i) = (1); (i) <= (n); ++(i)) for ((j) = (1); (j) <= (n); ++(j)) for ((o) = (0); (o) <= (l); ++(o)) if (f[i][j][o]) for ((k) = (1); (k) <= (n); ++(k)) if (tmp[j][k][l - o]) add(tmp[i][k][l], (long long)f[i][j][o] * tmp[j][k][l - o] % Mod); for ((i) = (1); (i) <= (n); ++(i)) for ((j) = (1); (j) <= (n); ++(j)) for ((l) = (0); (l) <= (2 * n); ++(l)) add(after[i][l], tmp[i][j][l]); } void Dp2(int f[MAX][MAX][MAX], int after[MAX][MAX]) { int i, j, k, l; for ((i) = (1); (i) <= (n); ++(i)) after[i][0] = 1; int up = 2 * n; for ((l) = (1); (l) <= (up); ++(l)) for ((i) = (1); (i) <= (n); ++(i)) for ((j) = (1); (j) <= (n); ++(j)) for ((k) = (0); (k) != (l); ++(k)) add(After[i][l], (long long)f[i][j][l - k] * After[j][k] % Mod); } void check(int a, int b) { int i, j; vector<int> &L = p[a][b]; int len = L.size(); for ((i) = (0); (i) <= (len - 2); ++(i)) if (L[i] == a && L[i + 1] == b) { vector<int> before, after; for (j = i; j >= 0; --j) before.push_back(L[j]); for (j = i + 1; j < len; ++j) after.push_back(L[j]); if (get(before, 2, 0, before.size()) && get(after, 1, 1, after.size())) { reverse(before.begin(), before.end()); int A = before[0]; int B = after[after.size() - 1]; int Len = before.size() + after.size() - 1; int l1, l2; for ((l1) = (0); (l1) <= (2 * n); ++(l1)) for ((l2) = (0); (l2) <= (2 * n); ++(l2)) if (l1 + l2 + Len <= 2 * n) add(ans[l1 + l2 + Len], (long long)Before[A][l1] * After[B][l2] % Mod); } else return; } return; } int main() { int i, j; scanf("%d%d", &n, &m); for ((i) = (1); (i) <= (m); ++(i)) { int a, b; scanf("%d%d", &a, &b); if (!