#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[200];
int tmp[200];
int q[200];
int s[200];
void first() {
  for (int i = 1; i <= n; i++) tmp[i] = p[q[i]];
  for (int i = 1; i <= n; i++) p[i] = tmp[i];
}
void second() {
  for (int i = 1; i <= n; i++) tmp[q[i]] = p[i];
  for (int i = 1; i <= n; i++) p[i] = tmp[i];
}
bool ok() {
  for (int i = 1; i <= n; i++)
    if (s[i] != p[i]) return 0;
  return 1;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) cin >> s[i];
  bool f_ok = 0, s_ok = 0;
  for (int i = 1; i <= n; i++) p[i] = i;
  if (ok()) {
    cout << "NO";
    return 0;
  }
  first();
  f_ok = ok();
  second();
  second();
  s_ok = ok();
  if (f_ok && s_ok) {
    if (k == 1)
      cout << "YES";
    else
      cout << "NO";
    return 0;
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= k; i++) {
    first();
    if (ok()) {
      if ((k - i) % 2 == 0) {
        cout << "YES";
        return 0;
      } else
        break;
    }
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= k; i++) {
    second();
    if (ok()) {
      if ((k - i) % 2 == 0) {
        cout << "YES";
        return 0;
      } else
        break;
    }
  }
  cout << "NO";
}

### Prompt

Your task is to create a CPP solution to the following problem:

Little Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n.

A permutation a of length n is a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ n), all integers there are distinct. 

There is only one thing Petya likes more than permutations: playing with little Masha. As it turns out, Masha also has a permutation of length n. Petya decided to get the same permutation, whatever the cost may be. For that, he devised a game with the following rules:

  * Before the beginning of the game Petya writes permutation 1, 2, ..., n on the blackboard. After that Petya makes exactly k moves, which are described below. 
  * During a move Petya tosses a coin. If the coin shows heads, he performs point 1, if the coin shows tails, he performs point 2.
    1. Let's assume that the board contains permutation p1, p2, ..., pn at the given moment. Then Petya removes the written permutation p from the board and writes another one instead: pq1, pq2, ..., pqn. In other words, Petya applies permutation q (which he has got from his mother) to permutation p. 
    2. All actions are similar to point 1, except that Petya writes permutation t on the board, such that: tqi = pi for all i from 1 to n. In other words, Petya applies a permutation that is inverse to q to permutation p. 



We know that after the k-th move the board contained Masha's permutation s1, s2, ..., sn. Besides, we know that throughout the game process Masha's permutation never occurred on the board before the k-th move. Note that the game has exactly k moves, that is, throughout the game the coin was tossed exactly k times.

Your task is to determine whether the described situation is possible or else state that Petya was mistaken somewhere. See samples and notes to them for a better understanding.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 100). The second line contains n space-separated integers q1, q2, ..., qn (1 ≤ qi ≤ n) — the permutation that Petya's got as a present. The third line contains Masha's permutation s, in the similar format.

It is guaranteed that the given sequences q and s are correct permutations.

Output

If the situation that is described in the statement is possible, print "YES" (without the quotes), otherwise print "NO" (without the quotes).

Examples

Input

4 1
2 3 4 1
1 2 3 4


Output

NO


Input

4 1
4 3 1 2
3 4 2 1


Output

YES


Input

4 3
4 3 1 2
3 4 2 1


Output

YES


Input

4 2
4 3 1 2
2 1 4 3


Output

YES


Input

4 1
4 3 1 2
2 1 4 3


Output

NO

Note

In the first sample Masha's permutation coincides with the permutation that was written on the board before the beginning of the game. Consequently, that violates the condition that Masha's permutation never occurred on the board before k moves were performed.

In the second sample the described situation is possible, in case if after we toss a coin, we get tails.

In the third sample the possible coin tossing sequence is: heads-tails-tails.

In the fourth sample the possible coin tossing sequence is: heads-heads.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[200];
int tmp[200];
int q[200];
int s[200];
void first() {
  for (int i = 1; i <= n; i++) tmp[i] = p[q[i]];
  for (int i = 1; i <= n; i++) p[i] = tmp[i];
}
void second() {
  for (int i = 1; i <= n; i++) tmp[q[i]] = p[i];
  for (int i = 1; i <= n; i++) p[i] = tmp[i];
}
bool ok() {
  for (int i = 1; i <= n; i++)
    if (s[i] != p[i]) return 0;
  return 1;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) cin >> s[i];
  bool f_ok = 0, s_ok = 0;
  for (int i = 1; i <= n; i++) p[i] = i;
  if (ok()) {
    cout << "NO";
    return 0;
  }
  first();
  f_ok = ok();
  second();
  second();
  s_ok = ok();
  if (f_ok && s_ok) {
    if (k == 1)
      cout << "YES";
    else
      cout << "NO";
    return 0;
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= k; i++) {
    first();
    if (ok()) {
      if ((k - i) % 2 == 0) {
        cout << "YES";
        return 0;
      } else
        break;
    }
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= k; i++) {
    second();
    if (ok()) {
      if ((k - i) % 2 == 0) {
        cout << "YES";
        return 0;
      } else
        break;
    }
  }
  cout << "NO";
}

```