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 = 1000000007;
long long fac[13];
int n, nunknown;
int a[100000];
int r[100000];
bool done[100000];
int todo[12], ntodo;
int sumtodo[1 << 12], cnttodo[1 << 12];
int cnt[100001];
bool twoswaps;
long long cur;
int nval;
int atval[100001];
int nxtval[1000000];
int prvval[1000000];
long long val[1000000];
long long invval[1000000];
long long mypow(long long x, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 1) return x * mypow(x, n - 1) % MOD;
  return mypow(x * x % MOD, n / 2);
}
long long inverse(long long a) { return mypow(a, MOD - 2); }
long long calcnext(int n, int k, long long pval, long long ppval) {
  return (ppval * (k - 1) % MOD + pval) * n % MOD;
}
long long calc() {
  long long ret = twoswaps ? cur : 1;
  return ret;
}
long long go(int left, int depth) {
  if (left == 0) return calc();
  long long ret = 0;
  for (int nleft = 0; nleft < left - nleft;
       nleft = (nleft + (1 << ntodo) - left) & left) {
    int now = left - nleft, i = sumtodo[now], j = cnt[i] + 1;
    ++cnt[i];
    int at = atval[i];
    long long pcur = cur;
    cur = cur * invval[at] % MOD;
    if (nxtval[at] == -1) {
      long long nxt = j == 1 ? i : calcnext(i, j, val[at], val[prvval[at]]);
      {
        val[nval] = nxt;
        invval[nval] = inverse(nxt);
        nxtval[nval] = -1;
        prvval[nval] = at;
        nxtval[at] = nval;
        ++nval;
      }
    }
    cur = cur * val[nxtval[at]] % MOD;
    atval[i] = nxtval[at];
    bool ptwoswaps = twoswaps;
    if (i > 2) twoswaps = true;
    long long sub = go(nleft, depth + 1);
    twoswaps = ptwoswaps;
    atval[i] = at;
    cur = pcur;
    --cnt[i];
    ret += fac[cnttodo[now] - 1] * sub % MOD;
  }
  return ret % MOD;
}
void run() {
  scanf("%d%d", &n, &nunknown);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = (0); i < (n); ++i) --a[i];
  memset(r, -1, sizeof(r));
  for (int i = (0); i < (n); ++i)
    if (a[i] != -1) r[a[i]] = i;
  memset(done, false, sizeof(done));
  memset(cnt, 0, sizeof(cnt));
  ntodo = 0;
  for (int i = (0); i < (n); ++i)
    if (a[i] == -1) {
      int ccnt = 0;
      for (int at = i; at != -1; at = r[at]) {
        done[at] = true;
        ++ccnt;
      }
      todo[ntodo++] = ccnt;
    }
  for (int i = (0); i < (n); ++i)
    if (!done[i]) {
      int ccnt = 0;
      for (int at = i; !done[at]; at = r[at]) {
        done[at] = true;
        ++ccnt;
      }
      cnt[ccnt]++;
    }
  sumtodo[0] = 0;
  for (int i = (0); i < (ntodo); ++i)
    for (int j = (0); j < (1 << i); ++j)
      sumtodo[j | (1 << i)] = sumtodo[j] + todo[i];
  cnttodo[0] = 0;
  for (int i = (0); i < (ntodo); ++i)
    for (int j = (0); j < (1 << i); ++j) cnttodo[j | (1 << i)] = cnttodo[j] + 1;
  cur = 1;
  twoswaps = false;
  nval = 0;
  memset(atval, -1, sizeof(atval));
  for (int i = (1); i <= (n); ++i) {
    if (cnt[i] > 0 && i > 2) twoswaps = true;
    {
      val[nval] = 1;
      invval[nval] = 1;
      nxtval[nval] = prvval[nval] = -1;
      atval[i] = nval;
      ++nval;
    }
    for (int j = (1); j <= (cnt[i]); ++j) {
      int at = atval[i];
      long long nxt = j == 1 ? i : calcnext(i, j, val[at], val[prvval[at]]);
      {
        val[nval] = nxt;
        invval[nval] = inverse(nxt);
        nxtval[nval] = -1;
        prvval[nval] = at;
        nxtval[at] = nval;
        atval[i] = nval;
        ++nval;
      }
    }
    cur = cur * val[atval[i]] % MOD;
  }
  long long ret = go((1 << ntodo) - 1, 0);
  cout << ret << endl;
}
int main() {
  fac[0] = 1;
  for (int i = (1); i <= (12); ++i) fac[i] = fac[i - 1] * i;
  run();
  return 0;
}