Problem: We are given a permutation sequence a1, a2, ..., an of numbers from 1 to n. Let's assume that in one second, we can choose some disjoint pairs (u1, v1), (u2, v2), ..., (uk, vk) and swap all aui and avi for every i at the same time (1 ≤ ui < vi ≤ n). The pairs are disjoint if every ui and vj are different from each other.

We want to sort the sequence completely in increasing order as fast as possible. Given the initial permutation, calculate the number of ways to achieve this. Two ways are different if and only if there is a time t, such that the set of pairs used for swapping at that time are different as sets (so ordering of pairs doesn't matter). If the given permutation is already sorted, it takes no time to sort, so the number of ways to sort it is 1.

To make the problem more interesting, we have k holes inside the permutation. So exactly k numbers of a1, a2, ..., an are not yet determined. For every possibility of filling the holes, calculate the number of ways, and print the total sum of these values modulo 1000000007 (109 + 7).

Input

The first line contains two integers n (1 ≤ n ≤ 105) and k (0 ≤ k ≤ 12). The second line contains the permutation sequence a1, ..., an (0 ≤ ai ≤ n). If a number is not yet determined, it is denoted as 0. There are exactly k zeroes. All the numbers ai that aren't equal to zero are distinct.

Output

Print the total sum of the number of ways modulo 1000000007 (109 + 7).

Examples

Input

5 0
1 5 2 4 3


Output

6


Input

5 2
1 0 2 4 0


Output

7

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
int ff[12 + 1], cnt[1 << 12], *dp[100000 + 1], *dq[100000 + 1];
int inv(int a) {
  return a == 1 ? 1
                : (long long)inv(a - 1000000007 % a) * (1000000007 / a + 1) %
                      1000000007;
}
void init() {
  int i, b, l;
  ff[0] = 1;
  for (i = 1; i <= 12; i++) ff[i] = (long long)ff[i - 1] * i % 1000000007;
  for (b = 1; b < 1 << 12; b++) cnt[b] = cnt[b & b - 1] + 1;
  for (l = 1; l <= 100000; l++) {
    dp[l] = (int *)malloc((100000 / l + 1) * sizeof *dp[l]);
    dq[l] = (int *)malloc((100000 / l + 1) * sizeof *dq[l]);
    dp[l][0] = 1, dp[l][1] = l;
    for (i = 2; i <= 100000 / l; i++)
      dp[l][i] =
          (dp[l][i - 1] + (long long)dp[l][i - 2] * (i - 1) % 1000000007) * l %
          1000000007;
    for (i = 0; i <= 100000 / l; i++) dq[l][i] = inv(dp[l][i]);
  }
}
int kk[100000 + 1], ll[1 << 12], k;
int solve(int b, int x, int simple) {
  int c, s, h, ans;
  if (b == (1 << k) - 1) return simple ? 1 : x;
  for (h = 0; h < k; h++)
    if ((b & 1 << h) == 0) break;
  c = (1 << k) - 1 ^ b ^ 1 << h;
  s = 0;
  ans = 0;
  do {
    int s_ = s | 1 << h, l = ll[s_];
    kk[l]++;
    ans = (ans + solve(b | s_,
                       (long long)x * dq[l][kk[l] - 1] % 1000000007 *
                           dp[l][kk[l]] % 1000000007 * ff[cnt[s]] % 1000000007,
                       simple && l <= 2)) %
          1000000007;
    kk[l]--;
  } while ((s = s - c & c));
  return ans;
}
int main() {
  static int pp[100000];
  static char head[100000], visited[100000];
  int n, i, j, b, x, l, simple;
  init();
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &pp[i]);
  memset(head, 1, n * sizeof *head);
  for (i = 0; i < n; i++) {
    scanf("%d", &pp[i]), pp[i]--;
    if (pp[i] != -1) head[pp[i]] = 0;
  }
  k = 0;
  for (i = 0; i < n; i++)
    if (head[i]) {
      for (j = i; j != -1; j = pp[j]) visited[j] = 1, ll[1 << k]++;
      k++;
    }
  for (b = 1; b < 1 << k; b++) ll[b] = ll[b & b - 1] + ll[b & -b];
  simple = 1;
  for (i = 0; i < n; i++)
    if (!visited[i]) {
      l = 0;
      for (j = i; !visited[j]; j = pp[j]) visited[j] = 1, l++;
      kk[l]++;
      if (l > 2) simple = 0;
    }
  x = 1;
  for (l = 1; l <= n; l++) x = (long long)x * dp[l][kk[l]] % 1000000007;
  printf("%d\n", solve(0, x, simple));
  return 0;
}