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;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
long long fastPow(long long x, long long y) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % 1000000007;
    x = x * x % 1000000007;
    y >>= 1;
  }
  return ans;
}
long long fac[100005];
int a[100005], pos[100005];
vector<long long> f[100005], nf[100005];
void init() {
  fac[0] = 1;
  for (int(i) = 1; (i) <= (int)(n); (i)++) fac[i] = fac[i - 1] * i % 1000000007;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    f[i].resize(n / i + 1);
    nf[i].resize(f[i].size());
    f[i][0] = 1;
    nf[i][0] = 1;
    for (int j = 1; j < f[i].size(); j++) {
      f[i][j] = f[i][j - 1] * i % 1000000007;
      if (j > 1) {
        f[i][j] += f[i][j - 2] * (j - 1) % 1000000007 * i % 1000000007;
      }
      f[i][j] %= 1000000007;
      nf[i][j] = fastPow(f[i][j], 1000000007 - 2);
    }
  }
}
bool vis[100005], r[100005];
vector<int> hole;
int cnt[100005], c[100005], c0, d[100005];
long long ss = 1, s2, ans;
void dfs(int x) {
  if (x == hole.size()) {
    long long s = ss, s3 = s2, xs = 1;
    for (int(i) = 0; (i) < (int)(c0); (i)++) {
      s3 += c[i] > 2;
      (s *= nf[c[i]][cnt[c[i]]]) %= 1000000007;
      cnt[c[i]]++;
      (s *= f[c[i]][cnt[c[i]]]) %= 1000000007;
      (xs *= fac[d[i] - 1]) %= 1000000007;
    }
    ans += (s3 ? s : 1) * xs % 1000000007;
    ans %= 1000000007;
    for (int(i) = 0; (i) < (int)(c0); (i)++) cnt[c[i]]--;
    return;
  }
  for (int(i) = 0; (i) < (int)(c0); (i)++) {
    c[i] += hole[x];
    d[i]++;
    dfs(x + 1);
    d[i]--;
    c[i] -= hole[x];
  }
  c[c0++] = hole[x];
  d[c0 - 1] = 1;
  dfs(x + 1);
  d[c0 - 1] = 0;
  c0--;
}
int main() {
  scanf("%d%d", &n, &k);
  init();
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d", a + i);
    pos[a[i]] = i;
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (a[i] == 0) {
      int cnt = 0;
      for (int j = i; j; j = pos[j]) {
        cnt++;
        vis[j] = 1;
      }
      hole.push_back(cnt);
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (!vis[i]) {
      int ct = 0;
      for (int j = i; !vis[j]; j = pos[j]) {
        ct++;
        vis[j] = 1;
      }
      cnt[ct]++;
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    (ss *= f[i][cnt[i]]) %= 1000000007;
    if (i > 2) s2 += cnt[i];
  }
  dfs(0);
  printf("%lld\n", ans);
  return 0;
}