#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N;
  cin >> N;
  long long frend[N + 1][N + 1];
  long long i, j, k;
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      cin >> frend[i][j];
    }
  }
  long long alex[N + 1];
  long long liking[N + 1];
  long long c = N + 9;
  for (i = 1; i <= N; i++) {
    cin >> alex[i];
    liking[alex[i]] = c--;
  }
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      if (frend[i][j] == i) continue;
      long long mx = 0;
      for (k = 1; k <= frend[i][j]; k++) {
        if (k == i) continue;
        mx = max(mx, liking[k]);
      }
      if (mx == liking[frend[i][j]]) {
        cout << frend[i][j] << " ";
        break;
      }
    }
  }
  cout << "\n";
}
