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>
using namespace std;
const int mo = 1e9 + 7;
long long ksm(long long x, long long y) {
  long long s = 1;
  for (; y; y /= 2, x = x * x % mo)
    if (y & 1) s = s * x % mo;
  return s;
}
const int N = 1e6 + 5;
int n, k, a[N], r[N], q[N];
long long fac[15];
vector<long long> f[N], nf[N];
int b[N], b0, cnt[N];
int c[N], c0, d[N];
long long ans, sum, s2;
void dg(int x) {
  if (x > b0) {
    long long s = sum, s3 = s2;
    for (int i = 1, B = c0; i <= B; i++) {
      s3 += c[i] > 2;
      s = s * nf[c[i]][cnt[c[i]]] % mo;
      cnt[c[i]]++;
      s = s * f[c[i]][cnt[c[i]]] % mo;
    }
    long long xs = 1;
    for (int i = 1, B = c0; i <= B; i++) xs = xs * fac[d[i] - 1] % mo;
    ans = (ans + (s3 ? s : 1) * xs) % mo;
    for (int i = 1, B = c0; i <= B; i++) cnt[c[i]]--;
    return;
  }
  for (int i = 1, B = c0; i <= B; i++) {
    c[i] += b[x];
    d[i]++;
    dg(x + 1);
    d[i]--;
    c[i] -= b[x];
  }
  c[++c0] = b[x];
  d[c0] = 1;
  dg(x + 1);
  d[c0] = 0;
  c0--;
}
int main() {
  fac[0] = 1;
  for (int i = 1, B = 15; i <= B; i++) fac[i] = fac[i - 1] * i % mo;
  scanf("%d %d", &n, &k);
  for (int i = 1, B = n; i <= B; i++) scanf("%d", &a[i]), r[a[i]]++;
  for (int i = 1, B = n; i <= B; i++) {
    f[i].resize(n / i + 1);
    nf[i].resize(n / i + 1);
    f[i][0] = 1;
    for (int j = 1, B = n / i; j <= B; j++) {
      f[i][j] = f[i][j - 1];
      if (j >= 2) f[i][j] = (f[i][j] + f[i][j - 2] * (j - 1)) % mo;
      f[i][j] = f[i][j] * i % mo;
    }
    long long s = 1;
    for (int j = 1, B = n / i; j <= B; j++) s = s * f[i][j] % mo;
    s = ksm(s, mo - 2);
    for (int j = n / i, B = 0; j >= B; j--) nf[i][j] = s, s = s * f[i][j] % mo;
    s = 1;
    for (int j = 1, B = n / i; j <= B; j++) {
      nf[i][j] = nf[i][j] * s % mo;
      s = s * f[i][j] % mo;
    }
  }
  for (int i = 1, B = n; i <= B; i++)
    if (!r[i]) {
      int x = i;
      q[x] = 1;
      b[++b0] = 0;
      do {
        b[b0]++;
        x = a[x];
        q[x] = 1;
      } while (x != 0);
    }
  for (int i = 1, B = n; i <= B; i++)
    if (!q[i]) {
      int x = i, len = 0;
      do {
        len++;
        x = a[x];
        q[x] = 1;
      } while (x != i);
      cnt[len]++;
    }
  sum = 1;
  for (int i = 1, B = n; i <= B; i++)
    sum = sum * f[i][cnt[i]] % mo, s2 += cnt[i] * (i > 2);
  dg(1);
  printf("%I64d", ans);
}