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 n, m;
const int N = 1e5 + 5;
const int mo = 1e9 + 7;
int k, p[N], bz[N], vis[N];
int chain[N], cir[N], cir1[N], ans1;
int top, len[N], num[N], ans;
vector<int> a[N], inv[N];
inline int pow(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = (long long)r * a % mo;
    a = (long long)a * a % mo;
    b >>= 1;
  }
  return r;
}
inline void pre() {
  for (int i = 1; i <= n; i++) {
    a[i].push_back(1);
    inv[i].push_back(1);
    for (int j = 1; i * j <= n; j++) {
      int tmp = (long long)a[i][j - 1] * i % mo;
      if (j >= 2)
        tmp = (tmp + (long long)a[i][j - 2] * (j - 1) % mo * i % mo) % mo;
      a[i].push_back(tmp);
      tmp = pow(tmp, mo - 2);
      inv[i].push_back(tmp);
    }
  }
}
inline void dp() {
  ans1 = 1;
  for (int i = 1; i <= n; i++) ans1 = (long long)ans1 * a[i][cir[i]] % mo;
}
inline void calc(int d) {
  int tmp = ans1;
  for (int i = 1; i <= top; i++) {
    int l = len[i];
    tmp = (long long)tmp * inv[l][cir[l]] % mo;
    cir[l]++, cir1[min(l, 3)]++;
    tmp = (long long)tmp * a[l][cir[l]] % mo;
  }
  if (cir1[3]) d = (long long)d * tmp % mo;
  ans = (ans + d) % mo;
  for (int i = 1; i <= top; i++) {
    int l = len[i];
    cir[l]--, cir1[min(l, 3)]--;
  }
}
inline void dfs(int now, int d) {
  if (now == k) {
    calc(d);
    return;
  }
  len[++top] = chain[now];
  num[top] = 1;
  dfs(now + 1, d);
  num[top--] = 0;
  for (int i = 1; i <= top; i++) {
    len[i] += chain[now];
    num[i]++;
    dfs(now + 1, (long long)d * (num[i] - 1) % mo);
    num[i]--;
    len[i] -= chain[now];
  }
}
inline void solve() {
  pre();
  int tot = 0;
  for (int i = 1; i <= n; i++)
    if (!bz[i]) {
      int x = i, y = 0;
      while (x) {
        vis[x] = 1;
        x = p[x];
        ++y;
      }
      chain[tot] = y;
      tot++;
    }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      int x = i, y = 1;
      while (x) {
        vis[x] = 1;
        if (p[x] == i) break;
        x = p[x];
        y++;
      }
      ++cir[y];
      ++cir1[min(y, 3)];
    }
  dp();
  dfs(0, 1);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    bz[p[i]] = 1;
  }
  solve();
  printf("%d\n", ans);
  return 0;
}