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;
int read() {
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    ;
  int x = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}
const int N = 1e5 + 5, S = (1 << 12) + 5, Mo = 1e9 + 7;
int pwr(int x, int y) {
  int z = 1;
  for (; y; y >>= 1, x = (long long)x * x % Mo)
    if (y & 1) z = (long long)z * x % Mo;
  return z;
}
int n, k, ans, ret, cnt[N], L[N], a[N], b[N], c[N], sum[S], ct[S], len, tot;
int fac[N], inv[N], pre[N << 5], f[N << 5], g[N << 5];
bool used[N], vis[N];
void dfs(int x) {
  len++;
  vis[x] = 1;
  if (a[x] && !vis[a[x]]) dfs(a[x]);
}
void calc(int s, int m) {
  if (s == (1 << k) - 1) {
    (ans += (m <= 2) ? 1 : ret) %= Mo;
    return;
  }
  int st = ((1 << k) - 1) ^ s, x = st & -st;
  for (int t = (st ^ x);; t = (t - 1) & (st ^ x)) {
    ret = (long long)ret * fac[ct[x | t] - 1] % Mo;
    int i = sum[x | t];
    ret = (long long)ret * g[L[i] + cnt[i]] % Mo;
    cnt[i]++;
    ret = (long long)ret * f[L[i] + cnt[i]] % Mo;
    calc(s | t | x, max(m, i));
    ret = (long long)ret * g[L[i] + cnt[i]] % Mo;
    cnt[i]--;
    ret = (long long)ret * f[L[i] + cnt[i]] % Mo;
    ret = (long long)ret * inv[ct[x | t] - 1] % Mo;
    if (!t) break;
  }
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    used[a[i]] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) len = 0, dfs(i), c[++c[0]] = len;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) len = 0, dfs(i), cnt[len]++;
  for (int i = 1; i <= n; i++) {
    f[L[i] = ++tot] = 1;
    for (int j = 1; j <= n / i; j++)
      f[tot + j] =
          ((long long)f[tot + j - 1] * i % Mo +
           ((j == 1) ? 0 : (long long)f[tot + j - 2] * i % Mo * (j - 1) % Mo)) %
          Mo;
    tot += n / i;
  }
  pre[0] = 1;
  for (int i = 1; i <= tot; i++) pre[i] = (long long)pre[i - 1] * f[i] % Mo;
  int mul = pwr(pre[tot], Mo - 2);
  for (int i = tot; i >= 1; i--) {
    g[i] = (long long)pre[i - 1] * mul % Mo;
    mul = (long long)mul * f[i] % Mo;
  }
  fac[0] = 1;
  for (int i = 1; i <= k; i++) fac[i] = fac[i - 1] * i;
  inv[k] = pwr(fac[k], Mo - 2);
  for (int i = k - 1; i >= 0; i--)
    inv[i] = (long long)inv[i + 1] * (i + 1) % Mo;
  ret = 1;
  int m = 0;
  for (int i = 1; i <= n; i++) {
    ret = (long long)ret * f[L[i] + cnt[i]] % Mo;
    if (cnt[i]) m = max(m, i);
  }
  for (int s = 0; s <= (1 << k) - 1; s++)
    for (int i = 1; i <= k; i++)
      if (s >> (i - 1) & 1) sum[s] += c[i], ct[s]++;
  calc(0, m);
  printf("%d\n", ans);
  return 0;
}