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>
const int N = 1000005;
const int mo = 1000000007;
using namespace std;
int n, m, a[N];
bool bz[N], bp[N];
vector<int> f[N], nf[N];
template <class I>
void read(I &x) {
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
long long ans, cnt, ap[20], sum;
long long d[20][2], js[20], mx, cd[N];
int num;
long long ksm(long long k, long long n) {
  long long s = 1;
  for (; n; n >>= 1, k = k * k % mo)
    if (n & 1) s = s * k % mo;
  return s;
}
void dfs(int k) {
  if (k > ap[0]) {
    long long v = 1, c = 0, mp = 0;
    for (int i = 1; i <= num; ++i) mp = max(mp, d[i][0]);
    if (max(mp, mx) > 2) {
      long long sv = ans;
      for (int i = 1; i <= num; ++i) {
        v = v * js[d[i][1] - 1] % mo;
        sv = sv * nf[d[i][0]][cd[d[i][0]]] % mo;
        cd[d[i][0]]++;
        sv = sv * (long long)f[d[i][0]][cd[d[i][0]]] % mo;
      }
      sum = (sum + sv * v) % mo;
      for (int i = 1; i <= num; ++i) cd[d[i][0]]--;
    } else {
      for (int i = 1; i <= num; ++i) v = v * js[d[i][1] - 1] % mo;
      sum = (sum + v) % mo;
    }
    return;
  }
  for (int i = 1; i <= num; ++i) {
    d[i][0] += ap[k];
    d[i][1]++;
    dfs(k + 1);
    d[i][1]--;
    d[i][0] -= ap[k];
  }
  d[++num][0] = ap[k];
  d[num][1] = 1;
  dfs(k + 1);
  d[num][1] = d[num][0] = 0;
  num--;
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), bz[a[i]] = 1;
  mx = 0;
  for (int i = 1; i <= n; ++i) {
    f[i].resize(n / i + 1);
    nf[i].resize(n / i + 1);
    long long v = i;
    f[i][0] = 1, f[i][1] = i;
    for (int j = 2; i * j <= n; j++)
      f[i][j] = (long long)i *
                ((long long)(j - 1) * f[i][j - 2] % mo + f[i][j - 1]) % mo,
      v = v * (long long)f[i][j] % mo;
    v = ksm(v, mo - 2);
    nf[i][0] = nf[i][1] = v;
    v = v * i % mo;
    for (int j = 2; i * j <= n; j++) nf[i][j] = v, v = v * f[i][j] % mo;
    v = 1;
    for (int j = n / i; j >= 0; --j)
      nf[i][j] = (long long)nf[i][j] * v % mo, v = v * f[i][j] % mo;
  }
  ans = 1, cnt = 0;
  js[0] = 1;
  for (int i = 1; i <= 19; ++i) js[i] = js[i - 1] * i % mo;
  sum = 0;
  f[0].push_back(0);
  for (int i = 1; i <= n; ++i) {
    if (!bz[i]) {
      bp[i] = 1;
      int c = 1, p = a[i];
      while (p != i && p != 0) bp[p] = 1, c++, p = a[p];
      ap[++ap[0]] = c;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!bp[i]) {
      bp[i] = 1;
      int c = 1, p = a[i];
      while (p != i && p != 0) bp[p] = 1, c++, p = a[p];
      mx = max(mx, (long long)c);
      cd[c]++;
    }
  }
  for (int i = 1; i <= n; ++i) {
    ans = ans * f[i][cd[i]] % mo;
  }
  num = 0;
  dfs(1);
  printf("%I64d\n", sum);
}