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;
template <class T>
bool chkmin(T& a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool chkmax(T& a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
void read(T& a) {
  char c = getchar_unlocked();
  T f = 1;
  a = 0;
  for (; !isdigit(c); c = getchar_unlocked())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar_unlocked()) a = a * 10 + c - '0';
  a *= f;
}
const int maxN = 1e5 + 5, mo = 1e9 + 7;
int pow_mod(int x, int t) {
  int ret = 1;
  while (t) {
    if (t & 1) ret = (long long)ret * x % mo;
    x = (long long)x * x % mo;
    t >>= 1;
  }
  return ret;
}
int a[maxN], N, M, tp, ans;
int cnt[4];
int pre;
int len[maxN], tot[maxN], lala[maxN], pos[maxN];
bool appear[maxN], vis[maxN];
vector<int> dp[maxN], invdp[maxN], chain;
void upd(int& a, int b) {
  a += b;
  if (a < 0) a += mo;
  if (a >= mo) a -= mo;
}
void prework() {
  for (int i = (1), _ = (N); i <= _; ++i) {
    dp[i].resize(N / i + 5);
    invdp[i].resize(N / i + 5);
    dp[i][0] = invdp[i][0] = 1;
    for (int j = (1), _ = (N / i + 2); j <= _; ++j) {
      dp[i][j] = (long long)dp[i][j - 1] * i % mo;
      if (j >= 2)
        upd(dp[i][j], (long long)dp[i][j - 2] * (j - 1) % mo * i % mo);
      invdp[i][j] = pow_mod(dp[i][j], mo - 2);
    }
  }
}
void calc(int haha) {
  int pre1 = (long long)pre * haha % mo;
  for (int i = (1), _ = (tp); i <= _; ++i) {
    pre1 = (long long)pre1 * invdp[len[i]][lala[len[i]]] % mo;
    cnt[min(len[i], 3)]++;
    pre1 = (long long)pre1 * dp[len[i]][++lala[len[i]]] % mo;
  }
  if (cnt[3] == 0) pre1 = haha;
  upd(ans, pre1);
  for (int i = (1), _ = (tp); i <= _; ++i) {
    lala[len[i]]--;
    cnt[min(len[i], 3)]--;
  }
}
void dfs(int x, int haha) {
  if (x >= (int)chain.size()) {
    calc(haha);
    return;
  }
  tot[++tp] = 1;
  len[tp] = chain[x];
  dfs(x + 1, haha);
  --tp;
  for (int i = (1), _ = (tp); i <= _; ++i) {
    tot[i]++;
    len[i] += chain[x];
    dfs(x + 1, (long long)haha * (tot[i] - 1) % mo);
    len[i] -= chain[x];
    tot[i]--;
  }
}
int main() {
  read(N);
  read(M);
  prework();
  for (int i = (1), _ = (N); i <= _; ++i) {
    read(a[i]);
    pos[a[i]] = i;
  }
  for (int i = (1), _ = (N); i <= _; ++i)
    if (a[i] == 0) {
      int len = 0;
      for (int x = i; x; x = pos[x]) vis[x] = 1, ++len;
      chain.push_back(len);
    }
  for (int i = (1), _ = (N); i <= _; ++i)
    if (vis[i] == 0) {
      int len = 0;
      for (int x = i; vis[x] == 0; x = pos[x]) vis[x] = 1, ++len;
      cnt[min(len, 3)]++;
      lala[len]++;
    }
  pre = 1;
  for (int i = (1), _ = (N); i <= _; ++i)
    if (lala[i]) pre = (long long)pre * dp[i][lala[i]] % mo;
  dfs(0, 1);
  cout << ans << endl;
  return 0;
}