#include <bits/stdc++.h>
using namespace std;
bool equalArrays(int *c1, int *c2, int n) {
  return (memcmp(c1, c2, n * sizeof(int)) == 0);
}
void permutate(int *c, int *p, int n) {
  int *c2 = new int[n];
  memcpy(c2, c, n * sizeof(int));
  for (int i = 0; i < n; i++) c[i] = c2[p[i]];
  delete[] c2;
}
void printArray(int *c, int n) {
  for (int i = 0; i < n; i++) cout << c[i] << ' ';
  cout << endl;
}
int main() {
  int n, k, *c, *s, *q, *t, i, i2, i3, qt = -1, tt = -1;
  cin >> n >> k;
  s = new int[n];
  c = new int[n];
  q = new int[n];
  t = new int[n];
  for (i = 0; i < n; i++) {
    cin >> i2;
    q[i] = i2 - 1;
  }
  for (i = 0; i < n; i++) {
    cin >> i2;
    s[i] = i2 - 1;
  }
  for (i = 0; i < n; i++) {
    t[q[i]] = i;
    c[i] = i;
  }
  if (equalArrays(c, s, n))
    cout << "NO";
  else {
    for (i = 0; i < k; i++) {
      permutate(c, q, n);
      if (equalArrays(c, s, n)) {
        qt = i + 1;
        break;
      }
    }
    for (i = 0; i < n; i++) c[i] = i;
    for (i = 0; i < k; i++) {
      permutate(c, t, n);
      if (equalArrays(c, s, n)) {
        tt = i + 1;
        break;
      }
    }
    if (qt == -1 && tt == -1)
      cout << "NO";
    else {
      if (qt == -1) {
        if ((tt - k) % 2 == 0)
          cout << "YES";
        else
          cout << "NO";
      } else {
        if (tt == -1) {
          if ((qt - k) % 2 == 0)
            cout << "YES";
          else
            cout << "NO";
        } else {
          if (qt == 1 && tt == 1 && k > 1)
            cout << "NO";
          else {
            if ((tt - k) % 2 == 0)
              cout << "YES";
            else {
              if ((qt - k) % 2 == 0)
                cout << "YES";
              else
                cout << "NO";
            }
          }
        }
      }
    }
  }
  delete[] c;
  delete[] s;
  delete[] q;
  delete[] t;
  return 0;
}
