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 mod = 1000000007;
int n, k;
int a[100010], ind[100010], vis[100010];
vector<int> chain;
vector<long long> f[100010], invf[100010];
long long fac[100010], inv[100010];
long long qp(long long a, long long p) {
  long long ans = 1;
  for (; p; p >>= 1, a = a * a % mod)
    if (p & 1) ans = ans * a % mod;
  return ans;
}
int num[100010];
int sta[100010], top;
int con[100010];
long long ans;
long long cans;
int bccnt;
void calc() {
  int i;
  long long tmp = 1;
  for (i = 1; i <= top; i++) {
    tmp = tmp * fac[con[i] - 1] % mod;
    tmp =
        tmp * invf[sta[i]][num[sta[i]]] % mod * f[sta[i]][++num[sta[i]]] % mod;
    if (sta[i] >= 3) bccnt++;
  }
  if (bccnt) {
    (ans += cans * tmp % mod) %= mod;
  } else {
    tmp = 1;
    for (i = 1; i <= top; i++) {
      tmp = tmp * fac[con[i] - 1] % mod;
    }
    (ans += tmp % mod) %= mod;
  }
  for (i = 1; i <= top; i++) {
    num[sta[i]]--;
    if (sta[i] >= 3) bccnt--;
  }
}
void dfs(int cur) {
  int i;
  if (cur == k) {
    calc();
    return;
  }
  sta[++top] = chain[cur];
  con[top] = 1;
  dfs(cur + 1);
  top--;
  for (i = 1; i <= top; i++) {
    sta[i] += chain[cur];
    con[i]++;
    dfs(cur + 1);
    sta[i] -= chain[cur];
    con[i]--;
  }
}
int main() {
  int i, j;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i]) ind[a[i]]++;
  }
  for (i = 1; i <= n; i++) {
    if (!ind[i]) {
      int now = i, cnt = 0;
      while (now) {
        vis[now] = 1;
        now = a[now];
        cnt++;
      }
      chain.push_back(cnt);
    }
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      int now = i, cnt = 1;
      while (1) {
        vis[now] = 1;
        if (now == a[now]) break;
        now = a[now];
        if (vis[now]) break;
        cnt++;
      }
      num[cnt]++;
    }
  }
  fac[0] = inv[0] = 1;
  for (i = 1; i < 100010; i++) fac[i] = fac[i - 1] * i % mod;
  inv[100010 - 1] = qp(fac[100010 - 1], mod - 2);
  for (i = 100010 - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
  for (i = 1; i <= n; i++) {
    f[i].push_back(1);
    invf[i].push_back(1);
    f[i].push_back(i);
    invf[i].push_back(qp(i, mod - 2));
    for (j = 2; j * i <= n; j++) {
      long long temp = f[i][j - 1] * i % mod;
      (temp += f[i][j - 2] * (j - 1) % mod * i % mod) %= mod;
      f[i].push_back(temp);
      invf[i].push_back(qp(temp, mod - 2));
    }
  }
  cans = 1;
  for (i = 1; i <= n; i++) {
    if (!num[i]) continue;
    cans = cans * f[i][num[i]] % mod;
    if (i >= 3) bccnt += num[i];
  }
  dfs(0);
  printf("%lld", ans);
  return 0;
}