#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<vector<int>> v(n + 1, vector<int>(n));
  for (long long i = 0; i < n; i++) {
    for (long long r = 0; r < n; r++) {
      int a;
      cin >> a;
      v[i][a - 1] = r;
    }
  }
  for (long long i = 0; i < n; i++) {
    int a;
    cin >> a;
    v[n][a - 1] = i;
  }
  vector<int> ans(n, -1);
  for (long long i = 0; i < n; i++) {
    int alx = INT_MAX, p = INT_MAX;
    for (long long r = 0; r < n; r++) {
      if (r != i) {
        alx = min(alx, v[n][r]);
        if (ans[i] == -1 or (v[i][ans[i]] > v[i][r] and v[n][r] == alx))
          ans[i] = r;
      }
    }
  }
  for (auto i : ans) cout << " " << i + 1;
  return 0;
}
