#include <bits/stdc++.h>
using namespace std;
vector<int> q, s, p;
vector<int> ff(const vector<int> &p) {
  vector<int> p2 = p;
  for (int(i) = (int)(0); (i) < (int)(p.size()); ++(i)) p2[i] = p[q[i]];
  return p2;
}
vector<int> rr(const vector<int> &p) {
  vector<int> p2 = p;
  for (int(i) = (int)(0); (i) < (int)(p.size()); ++(i)) p2[q[i]] = p[i];
  return p2;
}
int main() {
  int n, k;
  cin >> n >> k;
  q.resize(n), s.resize(n), p.resize(n);
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) cin >> q[i];
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) --q[i];
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) cin >> s[i];
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) --s[i];
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) p[i] = i;
  if (p == s) {
    cout << "NO" << endl;
    return 0;
  }
  if (ff(p) == rr(p)) {
    if (k == 1 && q == s) {
      cout << "YES" << endl;
      return 0;
    }
    cout << "NO" << endl;
    return 0;
  }
  int up = k + 1;
  int down = k + 1;
  for (int i = 0; i < k; ++i) {
    p = rr(p);
    if (p == s) {
      down = i + 1;
      break;
    }
  }
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) p[i] = i;
  for (int i = 0; i < k; ++i) {
    p = ff(p);
    if (p == s) {
      up = i + 1;
      break;
    }
  }
  if (up % 2 == k % 2 || down % 2 == k % 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
