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;
using ll = long long;
const ll mod = 1e9 + 7;
const int N = 1e5 + 5;
int n, k;
ll qpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % mod;
    }
    a = a * a % mod;
    b /= 2;
  }
  return res;
}
int thr_cnt = 0;
vector<vector<ll>> dp, invdp;
array<int, N> nxt, in, cnt;
array<bool, N> vis;
vector<int> cir, lis, tmp, cnt_lis;
ll ans = 0;
ll tmp_ans = 1;
void dfs(int x, ll addons) {
  if (x == k) {
    ll res = tmp_ans;
    for (auto v : tmp) {
      res = res * invdp[v][cnt[v]] % mod;
      ++cnt[v];
      res = res * dp[v][cnt[v]] % mod;
      thr_cnt += (v >= 3);
    }
    if (thr_cnt) {
      ans = (ans + addons * res % mod) % mod;
    } else {
      ans = (ans + addons) % mod;
    }
    for (auto v : tmp) {
      --cnt[v];
      thr_cnt -= (v >= 3);
    }
    return;
  }
  tmp.push_back(lis[x]);
  cnt_lis.push_back(1);
  dfs(x + 1, addons);
  tmp.pop_back();
  cnt_lis.pop_back();
  for (int i = 0; i < tmp.size(); i++) {
    tmp[i] += lis[x];
    ++cnt_lis[i];
    dfs(x + 1, addons * (cnt_lis[i] - 1) % mod);
    --cnt_lis[i];
    tmp[i] -= lis[x];
  }
}
int main() {
  cin >> n >> k;
  dp.resize(n + 1);
  invdp.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    dp[i].resize(n / i + 1);
    invdp[i].resize(n / i + 1);
    dp[i][0] = 1;
    invdp[i][0] = 1;
    for (int j = 1; j <= n / i; j++) {
      dp[i][j] = dp[i][j - 1] * i % mod;
      if (j >= 2) {
        dp[i][j] += dp[i][j - 2] * (j - 1) % mod * i % mod;
        dp[i][j] %= mod;
      }
      invdp[i][j] = qpow(dp[i][j], mod - 2);
    }
  }
  for (int i = 1; i <= n; i++) {
    int tmp;
    cin >> tmp;
    nxt[i] = tmp;
    if (!tmp) {
      continue;
    }
    in[tmp]++;
  }
  for (int i = 1; i <= n; i++) {
    if (!in[i]) {
      int len = 0;
      for (int j = i; j; j = nxt[j]) {
        len++;
        vis[j] = 1;
      }
      lis.push_back(len);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      int len = 0;
      for (int j = i; !vis[j]; j = nxt[j]) {
        len++;
        vis[j] = 1;
      }
      cir.push_back(len);
      if (len >= 3) {
        thr_cnt++;
      }
    }
  }
  for (auto v : cir) {
    cnt[v]++;
  }
  for (int i = 1; i <= n; i++) {
    tmp_ans = (tmp_ans * dp[i][cnt[i]]) % mod;
  }
  if (k == 0) {
    if (!thr_cnt) {
      cout << 1 << endl;
    } else {
      cout << tmp_ans << endl;
    }
    return 0;
  }
  dfs(0, 1);
  cout << ans << endl;
}