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 N = 1e5 + 3, mod = 1e9 + 7;
int n, m, ans, sum, smax, cnt[N], a[N], b[N];
int top, c[N], d[N];
bool vis[N], app[N];
vector<int> f[N], g[N];
inline long long fpm(long long x, int Exp) {
  long long res = 1;
  for (; Exp > 0; Exp >>= 1) {
    if (Exp & 1) res = res * x % mod;
    x = x * x % mod;
  }
  return res;
}
inline int calc_f(const int &x, const int &y) {
  if (f[x].size() <= y) {
    for (int i = (f[x].size()); i <= (y); ++i) {
      int ret1 = ((long long)f[x][i - 1] * x % mod +
                  (long long)f[x][i - 2] * x % mod * (i - 1) % mod) %
                 mod;
      int ret2 = fpm(ret1, mod - 2);
      f[x].push_back(ret1);
      g[x].push_back(ret2);
    }
  }
  return f[x][y];
}
inline int calc_g(const int &x, const int &y) { return g[x][y]; }
inline void Dfs(const int &x, const int &y) {
  if (x > m) {
    int curmax = smax, res = y;
    for (int i = (1); i <= (top); ++i) {
      int x = c[i];
      res = (long long)res * calc_g(x, cnt[x]) % mod;
      res = (long long)res * calc_f(x, ++cnt[x]) % mod;
      curmax = max(curmax, x);
    }
    if (curmax < 3)
      ans = (ans + 1) % mod;
    else
      ans = (ans + res) % mod;
    for (int i = (1); i <= (top); ++i) --cnt[c[i]];
    return;
  }
  ++top;
  c[top] = b[x];
  d[top] = 1;
  Dfs(x + 1, y);
  --top;
  for (int i = (1); i <= (top); ++i) {
    c[i] += b[x];
    ++d[i];
    Dfs(x + 1, (long long)y * (d[i] - 1) % mod);
    c[i] -= b[x];
    --d[i];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]), app[a[i]] = true;
  for (int i = (1); i <= (n); ++i)
    if (!app[i]) {
      b[++sum] = 1;
      vis[i] = true;
      for (int j = a[i]; j; j = a[j]) ++b[sum], vis[j] = true;
    }
  for (int i = (1); i <= (n); ++i)
    if (!vis[i]) {
      int cur = 1;
      vis[i] = true;
      for (int j = a[i]; j != i; j = a[j]) ++cur, vis[j] = true;
      ++cnt[cur];
    }
  for (int i = (1); i <= (n); ++i) {
    f[i].push_back(1);
    f[i].push_back(i);
    g[i].push_back(1);
    g[i].push_back(fpm(i, mod - 2));
  }
  long long tmp = 1;
  for (int i = (1); i <= (n); ++i)
    if (cnt[i]) {
      tmp = tmp * calc_f(i, cnt[i]) % mod;
      smax = i;
    }
  Dfs(1, tmp);
  printf("%d\n", ans);
  return 0;
}