#include <bits/stdc++.h>
using namespace std;
int n, k;
int q[110], s[110], markleft = -1, markright = -1;
int rec[210][110];
bool wrong = false;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> q[i];
    rec[100][i] = i;
  }
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= k; i++)
    for (int j = 1; j <= n; j++) {
      rec[100 + i][q[j]] = rec[100 + i - 1][j];
      rec[100 - i][j] = rec[100 - i + 1][q[j]];
    }
  for (int i = 1; i <= k; i++) {
    bool flag1 = true, flag2 = true;
    for (int j = 1; j <= n; j++)
      if (rec[100 + i][j] != s[j]) {
        flag1 = false;
        break;
      }
    if (flag1 && markleft == -1) markleft = i;
    for (int j = 1; j <= n; j++)
      if (rec[100 - i][j] != s[j]) {
        flag2 = false;
        break;
      }
    if (flag2 && markright == -1) markright = i;
  }
  bool flag = true;
  for (int i = 1; i <= n; i++)
    if (s[i] != i) {
      flag = false;
      break;
    }
  if (flag) wrong = true;
  if ((markleft == -1 && markright == -1) ||
      (markleft == 1 && markright == 1 && k != 1) || wrong)
    cout << "NO" << endl;
  else {
    if ((markleft != -1 && (k - markleft + 200) % 2 == 0) ||
        (markright != -1 && (k - markright + 200) % 2 == 0))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
