#include <bits/stdc++.h>
using namespace std;
int F[301][301], A[301], n;
int CAno[301];
int CFno[301];
void find_cards() {
  for (int f = 1; f <= n; ++f) {
    for (int i = 1; i <= n; ++i) CFno[F[f][i]] = n - i + 1;
    int res = 0;
    int Ac1 = 0, Ac2 = 0;
    int mom = 0;
    for (int c = 1; c <= n; ++c) {
      if (CAno[c] > CAno[Ac1]) {
        Ac2 = Ac1;
        Ac1 = c;
      } else if (CAno[c] > CAno[Ac2])
        Ac2 = c;
      if (Ac1 != f) {
        if (CFno[res] < CFno[Ac1]) {
          res = Ac1;
          mom = c;
        }
      } else if (CFno[res] < CFno[Ac2]) {
        res = Ac2;
        mom = c;
      }
    }
    cout << mom << ' ';
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) cin >> F[i][j];
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
    CAno[A[i]] = n - i + 1;
  }
  find_cards();
  cout << endl;
}
