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;
const int N = 1e5 + 10, K = 13;
int Pow(int x, int e) {
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1ll * ret * x % Mod;
    x = 1ll * x * x % Mod;
    e >>= 1;
  }
  return ret;
}
int fa[N], sz[N];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int cnt[N];
int A[N];
vector<int> dp[N], inv[N];
int n, k;
int len[K], sumlen[1 << K], fac[K];
int ans, way, mx;
int s, mask[K];
void DFS(int cur) {
  if (cur == k) {
    int nway = way, nmx = mx;
    for (int i = 1; i <= s; i++) {
      int x = sumlen[mask[i]];
      nway = 1ll * nway * inv[x][cnt[x]] % Mod * dp[x][cnt[x] + 1] % Mod *
             fac[__builtin_popcount(mask[i]) - 1] % Mod;
      nmx = max(nmx, x);
      ++cnt[x];
    }
    if (nmx <= 2)
      ans = (ans + 1) % Mod;
    else
      ans = (ans + nway) % Mod;
    for (int i = 1; i <= s; i++) {
      int x = sumlen[mask[i]];
      --cnt[x];
    }
  } else {
    mask[++s] = (1 << (cur));
    DFS(cur + 1);
    --s;
    for (int i = 1; i <= s; i++)
      mask[i] ^= (1 << (cur)), DFS(cur + 1), mask[i] ^= (1 << (cur));
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) fa[i] = i, sz[i] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
    if (A[i]) {
      int x = find(i), y = find(A[i]);
      if (x == y)
        cnt[sz[x]]++, sz[x] = -1;
      else
        fa[x] = y, sz[y] += sz[x];
    }
  }
  int c = 0;
  for (int i = 1; i <= n; i++)
    if (fa[i] == i && sz[i] != -1) len[c++] = sz[i];
  assert(c == k);
  for (int i = 0; i <= (1 << (c)) - 1; i++)
    for (int j = 0; j <= c - 1; j++)
      if (i & (1 << (j))) sumlen[i] += len[j];
  fac[0] = 1;
  for (int i = 1; i <= k; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
  for (int i = 1; i <= n; i++) {
    dp[i].resize(n / i + 1);
    dp[i][0] = 1;
    for (int j = 1; j <= n / i; j++) {
      dp[i][j] = 1ll * dp[i][j - 1] * i % Mod;
      if (j > 1) dp[i][j] = (dp[i][j] + 1ll * dp[i][j - 2] * (j - 1) * i) % Mod;
    }
    for (int j = 0; j <= n / i; j++) inv[i].push_back(Pow(dp[i][j], Mod - 2));
  }
  way = 1, mx = 0;
  for (int i = 1; i <= n; i++) {
    way = 1ll * way * dp[i][cnt[i]] % Mod;
    if (cnt[i]) mx = i;
  }
  DFS(0);
  printf("%d\n", ans);
  return 0;
}