#include <bits/stdc++.h>
using namespace std;
long long q[110], iq[110], n;
void go(long long tmp[], bool invert) {
  long long nw[n + 1];
  for (int i = 1; i <= n; i++) {
    if (invert) {
      nw[iq[i]] = tmp[i];
    } else {
      nw[q[i]] = tmp[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    tmp[i] = nw[i];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> q[i];
    iq[q[i]] = i;
  }
  long long s[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  bool check = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] != i) {
      check = 0;
    }
  }
  if (check) {
    cout << "NO\n";
    return 0;
  }
  check = 1;
  for (int i = 1; i <= n; i++) {
    if (q[i] != i) {
      check = 0;
    }
  }
  if (check) {
    for (int i = 1; i <= n; i++) {
      if (s[i] != i) {
        cout << "NO\n";
        return 0;
      }
    }
    if (k == 1) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
    return 0;
  }
  check = 1;
  for (int i = 1; i <= n; i++) {
    if (q[i] != iq[i]) {
      check = 0;
      break;
    }
  }
  long long tmp[n + 1];
  if (check) {
    for (int i = 1; i <= n; i++) {
      tmp[i] = i;
    }
    go(tmp, 0);
    for (int i = 1; i <= n; i++) {
      if (tmp[i] != s[i]) {
        check = 0;
        break;
      }
    }
    if (check) {
      if (k == 1) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
      return 0;
    }
    for (int i = 1; i <= n; i++) {
      tmp[i] = i;
    }
    go(tmp, 1);
    check = 1;
    for (int i = 1; i <= n; i++) {
      if (tmp[i] != s[i]) {
        check = 0;
        break;
      }
    }
    if (check) {
      if (k == 1) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    tmp[i] = i;
  }
  long long steps = -1;
  for (int i = 0; i < k; i++) {
    go(tmp, 0);
    bool ok = 1;
    for (int j = 1; j <= n; j++) {
      if (tmp[j] != s[j]) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      steps = i + 1;
    }
  }
  if (steps == -1 || (k - steps) % 2 == 1) {
    for (int i = 1; i <= n; i++) {
      tmp[i] = i;
    }
    for (int i = 0; i < k; i++) {
      go(tmp, 1);
      bool ok = 1;
      for (int j = 1; j <= n; j++) {
        if (tmp[j] != s[j]) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        steps = i + 1;
      }
    }
    if (steps == -1) {
      cout << "NO\n";
    } else {
      if ((k - steps) % 2) {
        cout << "NO\n";
      } else {
        cout << "YES\n";
      }
    }
  } else {
    cout << "YES\n";
  }
}
