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 = 1e9 + 7;
const int N = 1e5;
int n, k, p[200001], v[200001], a[200001], vv[200001], vis[200001], exist[100];
int judge = 0;
int pi, ans = 0, fac[200001], sz[200001], vp[200001];
vector<int> f[200001], vec[200001];
int mul(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = (long long)z * x % mo;
    x = (long long)x * x % mo;
  }
  return z;
}
void prework() {
  fac[0] = 1;
  for (long long i = 1; i <= N; i++) fac[i] = (long long)fac[i - 1] * i % mo;
  memset(vis, 0, sizeof(vis));
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= n; i++) v[p[i]] = i;
  int tot = 0;
  for (int i = 1; i <= n; i++)
    if (p[i] == 0) {
      int kx = i, cnt = 0;
      while (kx) {
        cnt++;
        vis[kx] = 1;
        kx = v[kx];
      }
      a[++tot] = cnt;
    }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    int kx = p[i], cnt = 1;
    vis[i] = 1;
    while (kx != i) {
      cnt++;
      vis[kx] = 1;
      kx = p[kx];
    }
    vv[cnt]++;
  }
}
void pre_dp() {
  pi = 1;
  for (int i = 1; i <= n; i++) {
    if (i > 2 && vv[i]) judge++;
    for (int j = 0; j <= vv[i] + k; j++) {
      f[i].push_back(0);
      vec[i].push_back(0);
    }
    f[i][0] = 1;
    vec[i][0] = 1;
    for (long long j = 1; j <= vv[i] + k; j++) {
      f[i][j] = (long long)f[i][j - 1] * i % mo;
      if (j >= 2)
        f[i][j] =
            ((long long)f[i][j] + (long long)f[i][j - 2] * (j - 1) % mo * i) %
            mo;
      vec[i][j] = mul(f[i][j], mo - 2);
    }
    pi = (long long)pi * f[i][vv[i]] % mo;
  }
}
void Insert(int l) {
  pi = (long long)pi * vec[l][vv[l]] % mo * f[l][vv[l] + 1] % mo;
  vv[l]++;
}
void Delete(int l, int bef) {
  vv[l]--;
  pi = bef;
}
void Update(int numx, int nowfac) {
  int now = pi;
  if (judge == 0) now = 1;
  ans = (ans + (long long)now * nowfac) % mo;
}
void DFS(int x, int nowx, int kl, int nowfac) {
  if (nowx == k + 1) {
    if (sz[x] > 2) judge++;
    int bef = pi;
    if (sz[x]) Insert(sz[x]);
    if (vp[x]) nowfac = (long long)nowfac * fac[vp[x] - 1] % mo;
    Update(x, nowfac);
    if (sz[x] > 2) judge--;
    if (sz[x]) Delete(sz[x], bef);
    return;
  }
  if (sz[x] == 0) {
    int kx = kl;
    while (exist[kx]) kx++;
    exist[kx] = 1;
    sz[x] += a[kx];
    vp[x]++;
    DFS(x, nowx + 1, kx + 1, nowfac);
    vp[x]--;
    sz[x] -= a[kx];
    exist[kx] = 0;
    return;
  }
  if (sz[x] > 2) judge++;
  long long bef = pi;
  Insert(sz[x]);
  DFS(x + 1, nowx, 1, (long long)nowfac * fac[vp[x] - 1] % mo);
  if (sz[x] > 2) judge--;
  Delete(sz[x], bef);
  for (int i = kl; i <= k; i++) {
    if (exist[i]) continue;
    exist[i] = 1;
    sz[x] += a[i];
    vp[x]++;
    DFS(x, nowx + 1, i + 1, nowfac);
    vp[x]--;
    sz[x] -= a[i];
    exist[i] = 0;
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  prework();
  pre_dp();
  for (int i = 1; i <= k; i++) exist[i] = 0;
  DFS(1, 1, 1, 1);
  ans = (ans % mo + mo) % mo;
  printf("%d\n", ans);
  return 0;
}