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 = 1e9 + 7, MAXN = 1e5 + 10;
int n, k;
int a[MAXN], deg[MAXN];
bool vis[MAXN];
vector<int> f[MAXN], Inv[MAXN];
int chain[20];
int cycle[MAXN];
int bitc[1 << 12], sum[1 << 12];
int fac[20];
int ans = 0, now = 1;
int c[20], cnt = 0;
int fpw(int x, int t) {
  if (!t) return 1;
  int o = fpw(x, t >> 1);
  o = 1ll * o * o % mod;
  if (t & 1) o = 1ll * o * x % mod;
  return o;
}
int inv(int x) { return fpw(x, mod - 2); }
void cal(int gg) {
  int last = now;
  for (int i = 1; i <= cnt; ++i) {
    int l = c[i];
    now = 1ll * now * Inv[l][cycle[l]] % mod;
    cycle[l]++;
    now = 1ll * now * f[l][cycle[l]] % mod;
  }
  if (cycle[1] + 2 * cycle[2] == n)
    ans = (ans + gg) % mod;
  else
    ans = (ans + 1ll * gg * now) % mod;
  now = last;
  for (int i = 1; i <= cnt; ++i) cycle[c[i]]--;
}
void solve(int state, int gg) {
  if (!state) {
    cal(gg);
    return;
  }
  int Q = ((state - 1) & state) ^ state, nstate = Q ^ state;
  for (int i = nstate;; i = (i - 1) & nstate) {
    ++cnt;
    c[cnt] = sum[i ^ Q];
    solve(state ^ i ^ Q, 1ll * gg * bitc[i ^ Q] % mod);
    --cnt;
    if (i == 0) break;
  }
}
void init() {
  for (int i = 1; i <= n; ++i) {
    f[i].push_back(1);
    f[i].push_back(i);
    Inv[i].push_back(1);
    Inv[i].push_back(inv(i));
    for (int j = 2; j <= n / i; ++j) {
      int nt =
          1ll * i * ((f[i][j - 1] + 1ll * (j - 1) * f[i][j - 2]) % mod) % mod;
      f[i].push_back(nt);
      Inv[i].push_back(inv(nt));
    }
  }
  fac[0] = fac[1] = 1;
  for (int i = 2; i <= 12; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
  bitc[0] = 0;
  for (int i = 0; i < k; ++i) {
    bitc[1 << i] = 1;
    sum[1 << i] = chain[i] + 1;
  }
  for (int i = 1; i < (1 << k); ++i) {
    if (bitc[i] > 0) continue;
    int j = ((i - 1) & i);
    bitc[i] = bitc[i ^ j] + bitc[j];
    sum[i] = sum[i ^ j] + sum[j];
  }
  for (int i = 1; i < (1 << k); ++i) bitc[i] = fac[bitc[i] - 1];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] > 0) deg[a[i]]++;
  }
  k = 0;
  for (int i = 1; i <= n; ++i)
    if (deg[i] == 0 && !vis[i]) {
      int len = 0;
      int pt = i;
      while (a[pt] > 0) {
        len++;
        vis[pt] = 1;
        pt = a[pt];
      }
      vis[pt] = 1;
      chain[k++] = len;
    }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      int pt = i, len = 0;
      if (a[pt] == i)
        cycle[1]++;
      else {
        vis[pt] = 1;
        pt = a[pt];
        len++;
        while (pt != i) {
          vis[pt] = 1;
          len++;
          pt = a[pt];
        }
        cycle[len]++;
      }
    }
  init();
  for (int i = 1; i <= n; ++i) now = 1ll * now * f[i][cycle[i]] % mod;
  int S = (1 << k) - 1;
  solve(S, 1);
  printf("%d\n", ans);
  return 0;
}