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;
vector<int> v[100005], l, sm[1 << 12];
int c[100005], p[100005], ip[100005];
int f[20];
bool s[100005];
int n, k;
void calc(int i) {
  v[i][0] = 1;
  v[i][1] = i;
  for (int j = (2); j < (int(v[i].size())); j++)
    v[i][j] = (i * (v[i][j - 1] + (j - 1) * 1ll * v[i][j - 2])) % 1000000007ll;
}
long long ans = 0;
void go(int m, int cr, bool r2) {
  if (m == 0) {
    if (r2)
      ans += cr;
    else
      ans += 1;
    if (ans >= 1000000007ll) ans -= 1000000007ll;
  } else {
    int t = 1 << __builtin_ctz(m);
    for (int st : sm[m ^ t]) {
      int gc = st | t;
      int nm = m ^ gc;
      int os = 0;
      int ml = 0;
      long long nr = cr;
      while (gc) {
        int ind = __builtin_ctz(gc);
        os += l[ind];
        gc ^= 1 << ind;
        ml++;
      }
      c[os]++;
      nr = (nr * v[os][c[os]]) % 1000000007ll;
      nr = (nr * f[ml - 1]) % 1000000007ll;
      go(nm, nr, r2 || (os > 2));
      c[os]--;
    }
  }
}
long long pw(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = (r * a) % 1000000007ll;
    a = (a * a) % 1000000007ll;
    b /= 2;
  }
  return r;
}
long long inv(long long x) { return pw(x, 1000000007ll - 2); }
int main() {
  scanf("%d%d", &n, &k);
  f[0] = 1;
  for (int i = (1); i < (20); i++) f[i] = (f[i - 1] * 1ll * i) % 1000000007ll;
  for (int i = (0); i < (1 << k); i++) {
    for (int j = (0); j < (1 << k); j++)
      if ((i & j) == j) {
        sm[i].push_back(j);
      }
  }
  for (int i = (1); i < (n + 1); i++) {
    scanf("%d", p + i);
    if (p[i]) ip[p[i]] = i;
  }
  for (int i = (1); i < (n + 1); i++)
    if (!ip[i]) {
      int r = 0;
      for (int j = i; j; j = p[j]) {
        s[j] = true;
        r++;
      }
      l.push_back(r);
    }
  assert(int(l.size()) == k);
  for (int i = (1); i < (n + 1); i++)
    if (!s[i]) {
      int r = 0;
      for (int j = i; !s[j]; j = p[j]) {
        s[j] = true;
        r++;
      }
      c[r]++;
    }
  long long res = 1;
  bool r2 = false;
  for (int i = (1); i < (n + 1); i++) {
    v[i].resize(c[i] + 13);
    calc(i);
    res = (res * v[i][c[i]]) % 1000000007ll;
    r2 |= c[i] && i > 2;
    for (int j = int(v[i].size()) - 1; j >= 1; j--) {
      v[i][j] = (v[i][j] * 1ll * inv(v[i][j - 1])) % 1000000007ll;
    }
  }
  go((1 << k) - 1, res, r2);
  printf("%lld\n", ans);
}