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;
int mod = 1000000007;
int mPow(int a, int x) {
  int ret = 1;
  while (x > 0) {
    if (x & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
    x >>= 1;
  }
  return ret;
}
int arr[100005], has[100005];
int used[100005];
vector<int> lines;
vector<int> dp[100005], rdp[100005];
int tmpAns = 1, gr3 = 0, answer = 0;
int cnt[100005];
vector<int> addSize, addCnt;
void updateAns(int ans) {
  int cur = tmpAns;
  for (int i = 0; i < addSize.size(); ++i) {
    cur = 1LL * cur * rdp[addSize[i]][cnt[addSize[i]]] % mod;
    ++cnt[addSize[i]];
    cur = 1LL * cur * dp[addSize[i]][cnt[addSize[i]]] % mod;
    if (addSize[i] > 2) ++gr3;
  }
  if (gr3) ans = 1LL * ans * cur % mod;
  for (int i = 0; i < addSize.size(); ++i) {
    --cnt[addSize[i]];
    if (addSize[i] > 2) --gr3;
  }
  answer = (answer + ans) % mod;
}
void dfs(int ind, int ans) {
  if (ind == lines.size()) {
    updateAns(ans);
    return;
  }
  addSize.push_back(lines[ind]);
  addCnt.push_back(1);
  dfs(ind + 1, ans);
  addSize.pop_back();
  addCnt.pop_back();
  for (int i = 0; i < addSize.size(); ++i) {
    addSize[i] += lines[ind];
    addCnt[i]++;
    dfs(ind + 1, 1LL * ans * (addCnt[i] - 1) % mod);
    addSize[i] -= lines[ind];
    addCnt[i]--;
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &arr[i]);
    has[arr[i]] = true;
  }
  for (int i = 1; i <= n; ++i) {
    dp[i].push_back(1);
    rdp[i].push_back(1);
    for (int j = 1; j * i <= n; ++j) {
      int val = 1LL * i * dp[i][j - 1] % mod;
      if (j > 1) {
        val = (val + 1LL * i * (j - 1) * dp[i][j - 2]) % mod;
      }
      dp[i].push_back(val);
      rdp[i].push_back(mPow(val, mod - 2));
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!has[i]) {
      int v = i, len = 0;
      while (v) {
        used[v] = true;
        ++len;
        v = arr[v];
      }
      lines.push_back(len);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      int v = i, len = 0;
      while (!used[v]) {
        used[v] = true;
        ++len;
        v = arr[v];
      }
      cnt[len]++;
      if (len >= 3) gr3++;
    }
  }
  for (int len = 1; len <= n; ++len)
    tmpAns = 1LL * tmpAns * dp[len][cnt[len]] % mod;
  dfs(0, 1);
  printf("%d\n", answer);
  return 0;
}