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 N = 100005;
const int mo = 1000000007;
inline int IN() {
  char ch;
  (ch = getchar());
  int f = 0, x = 0;
  for (; ((ch) == '\n' || (ch) == '\r' || (ch) == '\t' || (ch) == ' ');
       (ch = getchar()))
    ;
  if (ch == '-') f = 1, (ch = getchar());
  for (; !((ch) == '\n' || (ch) == '\r' || (ch) == '\t' || (ch) == ' ');
       (ch = getchar()))
    x = x * 10 + ch - '0';
  return (f) ? (-x) : (x);
}
int Pow(int x, int y, int p) {
  int A = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) A = (long long)A * x % p;
  return A;
}
vector<int> f[N], g[N];
int n;
int A, B, tot, c[N], len[N], num[N], ans[N], res, cnt, vis[N], lanlanlu[N];
int a[N];
void upd(int &x, int y) {
  if ((x += y) >= mo) x -= mo;
}
void mul(int x, int y) {
  if (!x)
    B += y;
  else
    A = 1ll * A * x % mo;
}
void dfs(int x, int an) {
  if (x > cnt) {
    int aa = A, bb = B;
    for (int i = (int)1; i <= (int)tot; i++) {
      int y = c[i];
      mul(g[y][ans[y]], -1);
      ans[y]++;
      mul(f[y][ans[y]], 1);
    }
    if (ans[1] + ans[2] * 2 == n) {
      ++res;
      res %= mo;
    } else {
      int tmp = (B) ? (0) : (A);
      res = (res + 1ll * tmp * an % mo) % mo;
    }
    for (int i = (int)1; i <= (int)tot; i++) ans[c[i]]--;
    A = aa;
    B = bb;
    return;
  }
  ++tot;
  c[tot] = len[x];
  num[tot] = 1;
  dfs(x + 1, an);
  --tot;
  for (int i = (int)1; i <= (int)tot; i++) {
    c[i] += len[x];
    num[i]++;
    dfs(x + 1, 1ll * an * (num[i] - 1) % mo);
    c[i] -= len[x];
    num[i]--;
  }
}
pair<int, int> dfs(int x) {
  vis[x] = 1;
  if (!a[x]) return make_pair(1, 0);
  if (vis[a[x]]) return make_pair(1, x);
  pair<int, int> tmp = dfs(a[x]);
  ++tmp.first;
  return tmp;
}
int main() {
  scanf("%d%*d", &n);
  for (int i = (int)1; i <= (int)n; i++) scanf("%d", a + i), lanlanlu[a[i]] = 1;
  f[0].push_back(1);
  g[0].push_back(1);
  for (int i = (int)1; i <= (int)n; i++) {
    f[i].push_back(1);
    g[i].push_back(1);
    for (int j = (int)1; j <= (int)n / i; j++) {
      f[i].push_back(0);
      g[i].push_back(0);
      if (j >= 1) upd(f[i][j], 1ll * f[i][j - 1] * i % mo);
      if (j >= 2) upd(f[i][j], 1ll * f[i][j - 2] * i % mo * (j - 1) % mo);
      g[i][j] = Pow(f[i][j], mo - 2, mo);
    }
  }
  for (int i = (int)1; i <= (int)n; i++) {
    if (a[i] == 0) continue;
    if (vis[i]) continue;
    if (lanlanlu[i]) continue;
    pair<int, int> tmp = dfs(i);
    len[++cnt] = tmp.first;
  }
  for (int i = (int)1; i <= (int)n; i++)
    if (!vis[i] && a[i] == 0) len[++cnt] = 1;
  for (int i = (int)1; i <= (int)n; i++)
    if (!vis[i] && a[i] != 0) {
      ans[dfs(i).first]++;
    }
  A = 1;
  B = 0;
  for (int i = (int)1; i <= (int)n; i++) mul(f[i][ans[i]], 1);
  dfs(1, 1);
  printf("%d\n", res);
  return 0;
}