#include <bits/stdc++.h>
using namespace std;
int B[400], A[400][400];
int main() {
  int n, i, j, b, res, id, x;
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) cin >> x, A[i][x] = j;
  for (i = 1; i <= n; i++) cin >> x, B[x] = i;
  for (i = 1; i <= n; i++) {
    res = ((int)1e9), id = -1, b = ((int)1e9);
    for (j = 1; j <= n; j++) {
      if (i == j) continue;
      b = min(b, B[j]);
      if (b == B[j] && res > A[i][j]) res = A[i][j], id = j;
    }
    cout << id << " ";
  }
  return 0;
}
