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 mo = 1000000007;
const double pi = acos(-1);
int *f[120000], *ni_f[120000], tmpx, tmpy, ans, tot, K, q[120], n;
int g_sum[120000], g_num[120000], num[120000], pos[120000], a[120000],
    vis[120000];
int Pow(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = 1ll * res * x % mo;
    x = 1ll * x * x % mo;
    y /= 2;
  }
  return res;
}
void mul(int x, int flag) {
  if (!x)
    tmpx += flag;
  else
    tmpy = 1ll * tmpy * x % mo;
}
void work(int x, int y) {
  f[x][0] = ni_f[x][0] = 1;
  for (int i = 1; i <= y; ++i) {
    f[x][i] = 1ll * f[x][i - 1] * x % mo;
    if (i >= 2) f[x][i] = (f[x][i] + 1ll * f[x][i - 2] * x % mo * (i - 1)) % mo;
    ni_f[x][i] = Pow(f[x][i], mo - 2);
  }
}
void dfs(int x, int res) {
  if (x > K) {
    int ttmpx = tmpx, ttmpy = tmpy;
    for (int i = 1; i <= tot; ++i) {
      int y = g_sum[i];
      mul(ni_f[y][num[y]], -1);
      num[y]++;
      mul(f[y][num[y]], 1);
    }
    if (num[1] + num[2] * 2 == n)
      ans = (ans + 1) % mo;
    else
      ans = (ans + 1ll * (tmpx ? 0 : tmpy) * res) % mo;
    for (int i = 1; i <= tot; ++i) num[g_sum[i]]--;
    tmpx = ttmpx;
    tmpy = ttmpy;
    return;
  }
  g_sum[++tot] = q[x];
  g_num[tot] = 1;
  dfs(x + 1, res);
  tot--;
  for (int i = 1; i <= tot; ++i) {
    g_sum[i] += q[x];
    g_num[i]++;
    dfs(x + 1, 1ll * res * (g_num[i] - 1) % mo);
    g_sum[i] -= q[x];
    g_num[i]--;
  }
}
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), pos[a[i]] = i;
  for (int i = 1; i <= n; ++i)
    if (!a[i]) {
      int cnt = 0;
      for (int j = i; j; j = pos[j]) vis[j] = 1, cnt++;
      q[++tot] = cnt;
    }
  assert(tot == K);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      int cnt = 0;
      for (int j = i; !vis[j]; j = pos[j]) vis[j] = 1, cnt++;
      num[cnt]++;
    }
  for (int i = 1; i <= n; ++i) {
    f[i] = new int[n / i + 2];
    ni_f[i] = new int[n / i + 2];
    work(i, n / i);
  }
  tmpy = 1;
  for (int i = 1; i <= n; ++i) mul(f[i][num[i]], 1);
  tot = 0;
  dfs(1, 1);
  printf("%d\n", ans);
}