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 Mod = (1e9) + 7;
const int Maxn = 100005;
int s1[20], s2[20];
int s[Maxn], jc[Maxn];
int pre[Maxn], nxt[Maxn];
int sum_chain, len_chain[20];
int sum_circle, len_circle[Maxn];
int n, k, i, j, cot1, cot2, base, ans, cnt;
bool flag, vis[Maxn];
vector<int> f[Maxn], g[Maxn];
int qck(int a, int b) {
  int ret = 1;
  for (; b > 0; b >>= 1) {
    if (b & 1) ret = (long long)ret * a % Mod;
    a = (long long)a * a % Mod;
  }
  return ret;
}
void dfs(int x) {
  if (x > sum_chain) {
    int tmp = base;
    bool ff = flag;
    for (int i = 1; i <= cnt; i++) {
      int len = s2[i];
      tmp = (long long)tmp * g[len][s[len]] % Mod * f[len][s[len] + 1] % Mod;
      tmp = (long long)tmp * jc[s1[i] - 1] % Mod;
      s[len]++;
      if (s2[i] > 2) ff = 1;
    }
    if (ff == 1)
      ans += tmp;
    else
      ans++;
    if (ans > Mod) ans -= Mod;
    for (int i = 1; i <= cnt; i++) s[s2[i]]--;
    return;
  }
  for (int i = 1; i <= cnt; i++) {
    s1[i]++;
    s2[i] += len_chain[x];
    dfs(x + 1);
    s1[i]--;
    s2[i] -= len_chain[x];
  }
  cnt++;
  s1[cnt]++;
  s2[cnt] += len_chain[x];
  dfs(x + 1);
  s1[cnt]--;
  s2[cnt] -= len_chain[x];
  cnt--;
}
void init() {
  for (i = 1; i <= n; i++) {
    f[i].push_back(1);
    f[i].push_back(i);
    g[i].push_back(1);
    g[i].push_back(qck(i, Mod - 2));
    for (j = 2; i * j <= n; j++) {
      f[i].push_back(((long long)f[i][j - 1] * i % Mod +
                      (long long)(j - 1) * f[i][j - 2] % Mod * i % Mod) %
                     Mod);
      g[i].push_back(qck(f[i][j], Mod - 2));
    }
  }
  for (i = 1, jc[0] = 1; i <= n; i++) jc[i] = (long long)jc[i - 1] * i % Mod;
}
int main() {
  scanf("%d%d", &n, &k);
  init();
  for (i = 1; i <= n; i++) {
    scanf("%d", &nxt[i]);
    if (nxt[i]) pre[nxt[i]] = i;
  }
  for (i = 1; i <= n; i++)
    if (pre[i] == 0) {
      sum_chain++;
      for (j = i; j > 0; j = nxt[j]) {
        len_chain[sum_chain]++;
        vis[j] = 1;
      }
    }
  base = 1;
  for (i = 1; i <= n; i++)
    if (vis[i] == 0) {
      sum_circle++;
      for (j = i; vis[j] == 0; j = nxt[j]) {
        len_circle[sum_circle]++;
        vis[j] = 1;
      }
      int tmp = len_circle[sum_circle];
      base = (long long)base * qck(f[tmp][s[tmp]], Mod - 2) % Mod *
             f[tmp][s[tmp] + 1] % Mod;
      s[tmp]++;
      if (tmp > 2) flag = 1;
    }
  dfs(1);
  printf("%d\n", ans);
  return 0;
}