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 maxn = 100050, maxk = 15, mod = 1e9 + 7;
vector<pair<int, int> > f[maxn];
int n, K, a[maxn], ans = 0;
int in[maxn];
bool vis[maxn];
int ch[maxk][maxn], len[maxk], cs = 0;
int cnt[maxn];
int l0[maxk], cnt0[maxk];
inline int Pow(int x, int k) {
  int s = 1;
  for (; k; k >>= 1, x = 1LL * x * x % mod)
    if (k & 1) s = 1LL * s * x % mod;
  return s;
}
void init() {
  int i, j, t;
  for (i = 1; i < maxn; i++) {
    f[i].push_back(make_pair(1, 1)),
        f[i].push_back(make_pair(i, Pow(i, mod - 2)));
    for (j = 2; i * j < maxn; j++) {
      t = (1LL * f[i][j - 2].first * (j - 1) + f[i][j - 1].first) % mod * i %
          mod;
      f[i].push_back(make_pair(t, Pow(t, mod - 2)));
    }
  }
}
void dfs(int x, int s, int cur, int c) {
  if (x == K) {
    ans = (ans + 1LL * c * (cnt[1] + cnt[2] * 2 == n ? 1 : cur)) % mod;
    return;
  }
  int i, t;
  l0[s] = len[x];
  cnt0[s] = 0;
  dfs(x + 1, s + 1, cur, c);
  for (i = 0; i < s; i++) {
    t = 1LL * cur * f[len[x]][cnt[len[x]]].second % mod *
        f[len[x]][cnt[len[x]] - 1].first % mod;
    cnt[len[x]]--;
    t = 1LL * t * f[l0[i]][cnt[l0[i]]].second % mod *
        f[l0[i]][cnt[l0[i]] - 1].first % mod;
    cnt[l0[i]]--;
    l0[i] += len[x];
    t = 1LL * t * f[l0[i]][cnt[l0[i]]].second % mod *
        f[l0[i]][cnt[l0[i]] + 1].first % mod;
    cnt[l0[i]]++;
    cnt0[i]++;
    dfs(x + 1, s, t, c * cnt0[i]);
    cnt0[i]--;
    cnt[l0[i]]--;
    l0[i] -= len[x];
    cnt[l0[i]]++;
    cnt[len[x]]++;
  }
}
int main() {
  int i, j, k, cur = 1;
  init();
  scanf("%d%d", &n, &K);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), in[a[i]]++;
  for (i = 1; i <= n; i++)
    if (!in[i]) {
      for (j = i; j; j = a[j]) vis[j] = 1, ch[cs][len[cs]++] = j;
      cnt[len[cs]]++;
      cs++;
    }
  for (i = 1; i <= n; i++)
    if (!vis[i] && in[i]) {
      for (j = a[i], k = 1; j != i; j = a[j]) vis[j] = 1, k++;
      cnt[k]++;
    }
  for (i = 1; i <= n; i++) cur = 1LL * cur * f[i][cnt[i]].first % mod;
  dfs(0, 0, cur, 1);
  printf("%d\n", ans);
  return 0;
}