#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 10;
int n, m, k;
vector<int> copy(vector<int>& v) { return v; }
void qq(vector<int>& v, vector<int>& q) {
  vector<int> v2;
  v2.resize((int)v.size());
  for (int i = 1; i <= n; i++) v2[i] = v[q[i]];
  v = copy(v2);
}
bool eq(vector<int>& x, vector<int>& y) {
  for (int i = 1; i <= n; i++)
    if (x[i] != y[i]) return false;
  return true;
}
int main() {
  vector<int> q(MAXN), q2(MAXN), s(MAXN), a(MAXN);
  cin >> n;
  cin >> k;
  for (int i = 1; i <= n; i++) {
    cin >> q[i];
    a[i] = i;
  }
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++) q2[q[i]] = i;
  if (eq(a, s)) {
    cout << "NO";
    exit(0);
  }
  for (int i = 0; i < k;) {
    qq(a, q);
    i++;
    if (eq(a, s)) {
      if (i != k && eq(q, q2)) {
        cout << "NO";
        exit(0);
      }
      if ((k - i) % 2 == 0) {
        cout << "YES";
        exit(0);
      }
      break;
    }
  }
  for (int i = 1; i <= n; i++) a[i] = i;
  for (int i = 0; i < k;) {
    qq(a, q2);
    i++;
    if (eq(a, s)) {
      if ((k - i) % 2 == 0) {
        cout << "YES";
        exit(0);
      }
      break;
    }
  }
  cout << "NO";
}
