#include <bits/stdc++.h>
using namespace std;
long a[307][307], b[307], n, t[307], bst, sec, w[307];
void read(void) {
  cin >> n;
  for (long i = 1; i <= n; ++i)
    for (long x, j = 1; j <= n; ++j) {
      cin >> x;
      a[i][x] = j;
    }
  for (long x, i = 1; i <= n; ++i) {
    cin >> x;
    b[x] = i;
    a[i][303] = 303;
    t[i] = 303;
  }
  bst = sec = 303;
  b[303] = 303;
}
void kill(void) {
  for (long i = 1; i <= n; ++i) {
    if (b[i] < b[bst]) {
      sec = bst;
      bst = i;
    } else if (b[i] < b[sec])
      sec = i;
    for (long j = 1; j <= n; ++j) {
      if (bst != j && a[j][bst] < a[j][t[j]]) t[j] = bst, w[j] = i;
      if (sec != j && bst == j)
        if (a[j][sec] < a[j][t[j]]) t[j] = sec, w[j] = i;
    }
  }
  for (long j = 1; j <= n; ++j) cout << w[j] << " ";
}
int main() {
  read();
  kill();
  return 0;
}
