#include <bits/stdc++.h>
using namespace std;
vector<long long> getperm(vector<long long> a, vector<long long> b) {
  long long i;
  vector<long long> c;
  for (i = 0; i < b.size(); i++) {
    c.push_back(a[b[i] - 1]);
  }
  a.clear();
  return c;
}
vector<long long> getIncPerm(vector<long long> a, vector<long long> b) {
  long long i;
  vector<long long> c;
  for (i = 0; i < b.size(); i++) c.push_back(1);
  for (i = 0; i < b.size(); i++) {
    c[b[i] - 1] = a[i];
  }
  a.clear();
  return c;
}
vector<long long> vec, vec2, vec3;
int main() {
  long long t, n, i, j, k, l, m;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  t = 1;
  for (long long T = 1; T <= t; T++) {
    cin >> n >> k;
    for (i = 0; i < n; i++) cin >> j, vec2.push_back(j);
    for (i = 0; i < n; i++) cin >> j, vec3.push_back(j);
    for (i = 0; i < n; i++) cin >> j, vec.push_back(i + 1);
    if (vec == vec3) {
      cout << "NO" << '\n';
      return 0;
    }
    long long op = k;
    long long ans1 = -1, ans2 = -1;
    while (op--) {
      vec = getperm(vec, vec2);
      bool flag = false;
      for (i = 0; i < vec.size(); i++)
        if (vec[i] != vec3[i]) flag = true;
      if (!flag) {
        ans1 = k - op;
        break;
      }
    }
    op = k;
    vec.clear();
    for (i = 1; i <= n; i++) vec.push_back(i);
    while (op--) {
      vec = getIncPerm(vec, vec2);
      bool flag = false;
      for (i = 0; i < vec.size(); i++)
        if (vec[i] != vec3[i]) flag = true;
      if (!flag) {
        ans2 = k - op;
        break;
      }
    }
    bool ans = 0;
    if (ans1 == k || ans2 == k) ans = 1;
    if (((ans1 != -1 && ans1 % 2 == k % 2) ||
         (ans2 != -1 && ans2 % 2 == k % 2)) &&
        (ans2 != 1 || ans1 != 1))
      ans = 1;
    if (ans)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
