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 maxn = 2e5 + 222;
const int mod = 1e9 + 7;
using ll = long long;
const int lim = 1e6;
int n, k, p[maxn], len, ans, mul = 1, one, max, vis[maxn], s[maxn], cnt[maxn],
                             f[maxn], fac[maxn], in[maxn], g[maxn],
                             iv[lim + 100];
std::vector<int> chain, cycle;
std::vector<int> F[maxn];
int cw[maxn];
int inv(int x) {
  return x <= lim ? iv[x] : (ll)(mod - mod / x) * inv(mod % x) % mod;
}
void extend(int x, int f = 1) {
  if (f) mul = (ll)mul * inv(F[x].back()) % mod;
  cw[x]++;
  F[x].push_back((ll)x *
                 (F[x][cw[x] - 1] +
                  (cw[x] > 1 ? (ll)(cw[x] - 1) * F[x][cw[x] - 2] % mod : 0)) %
                 mod);
  if (f) mul = (ll)mul * F[x].back() % mod;
}
void erase(int x, int f = 1) {
  if (f) mul = (ll)mul * inv(F[x].back()) % mod;
  cw[x]--;
  F[x].pop_back();
  if (f) mul = (ll)mul * F[x].back() % mod;
}
void dfs(int u, int lim) {
  if (u == len) {
    int x = max;
    int way = 1;
    for (int i = 1; i <= lim; ++i) {
      assert(1 <= cnt[i] && cnt[i] <= n);
      way = (ll)way * fac[cnt[i] - 1] % mod;
      x = std::max(x, s[i]);
    }
    if (x == 1) {
      ans = (ans + way) % mod;
    } else if (x == 2) {
      ans = (ans + way) % mod;
    } else {
      ans = (ans + (ll)mul * way % mod) % mod;
    }
    return;
  }
  for (int i = 1; i <= lim + 1; ++i) {
    int prev = mul;
    if (s[i]) erase(s[i]);
    s[i] += chain[u];
    extend(s[i]);
    cnt[i]++;
    dfs(u + 1, std::max(lim, i));
    cnt[i]--;
    if (s[i]) erase(s[i], 0);
    s[i] -= chain[u];
    if (s[i]) extend(s[i], 0);
    mul = prev;
  }
}
int main() {
  scanf("%d%d", &n, &k);
  f[0] = f[1] = fac[0] = g[0] = 1;
  iv[1] = 1;
  for (int i = 2; i <= lim; ++i)
    iv[i] = (ll)(mod - mod / i) * iv[mod % i] % mod;
  for (int i = 1; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
  for (int i = 2; i <= n; ++i)
    f[i] = (f[i - 1] + (ll)(i - 1) * f[i - 2] % mod) % mod;
  for (int i = 2; i <= n; i += 2) g[i] = (ll)g[i - 2] * (i - 1) % mod;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
    in[p[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (!in[i]) {
      int u = i, c = 0;
      while (u) {
        vis[u] = 1;
        c++;
        u = p[u];
      }
      chain.push_back(c);
    }
  }
  for (int i = 1; i <= n; ++i) {
    F[i].push_back(1);
    if (!vis[i]) {
      int u = i, c = 0;
      while (!vis[u]) {
        vis[u] = 1;
        c++;
        u = p[u];
      }
      cycle.push_back(c);
    }
  }
  for (int c : cycle) {
    max = std::max(max, c);
    extend(c);
  }
  len = chain.size();
  dfs(0, 0);
  printf("%d", ans);
  return 0;
}