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 MAXN = 100000 + 10, MOD = (int)1e9 + 7;
int n, k, a[MAXN], b[MAXN], c[MAXN], Tohka, Mashiro = 1, v[MAXN];
vector<int> f[MAXN], Invf[MAXN];
bool vis[MAXN], del[MAXN];
int Pow(int a, int b) {
  int d = 1;
  for (; b; d = (b & 1) ? (long long)d * a % MOD : d,
            a = (long long)a * a % MOD, b /= 2)
    ;
  return d;
}
int top, l[MAXN], s[MAXN];
void Calc(int num) {
  int tmp = Mashiro;
  for (int i = 1; i <= top; ++i) {
    ++c[min(l[i], 3)];
    tmp =
        (long long)tmp * Invf[l[i]][b[l[i]]] % MOD * f[l[i]][b[l[i]] + 1] % MOD;
    ++b[l[i]];
  }
  if (c[3]) num = (long long)num * tmp % MOD;
  for (int i = 1; i <= top; ++i) --c[min(l[i], 3)], --b[l[i]];
  Tohka = (Tohka + num) % MOD;
}
void DFS(int first, int num) {
  if (first > k) {
    Calc(num);
    return;
  }
  l[++top] = v[first];
  s[top] = 1;
  DFS(first + 1, num);
  --top;
  for (int i = 1; i <= top; ++i) {
    l[i] += v[first], ++s[i];
    DFS(first + 1, (long long)num * (s[i] - 1) % MOD);
    l[i] -= v[first], --s[i];
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    f[i].resize(n / i + 2);
    Invf[i].resize(n / i + 2);
    f[i][0] = Invf[i][0] = 1;
    for (int j = 1; j * i <= n; ++j) {
      f[i][j] = (long long)f[i][j - 1] * i % MOD;
      if (j >= 2)
        f[i][j] =
            ((long long)f[i][j] + (long long)f[i][j - 2] * (j - 1) % MOD * i) %
            MOD;
      Invf[i][j] = Pow(f[i][j], MOD - 2);
    }
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    vis[a[i]] = true;
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      int cnt = 0;
      for (int first = i; first; first = a[first]) del[first] = true, ++cnt;
      v[++v[0]] = cnt;
    }
  for (int i = 1; i <= n; ++i)
    if (!del[i]) {
      int cnt = 1;
      for (int first = i; a[first] != i; first = a[first])
        del[first] = del[a[first]] = true, ++cnt;
      ++b[cnt], ++c[min(3, cnt)];
    }
  for (int i = 1; i <= n; ++i)
    Mashiro = ((long long)Mashiro * f[i][b[i]]) % MOD;
  DFS(1, 1);
  cout << Tohka << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}