#include <bits/stdc++.h>
using namespace std;
int B[400], A[400][400];
int main() {
  int n, i, j, b, res, id, x;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) scanf("%d", &x), A[i][x - 1] = j;
  for (i = 0; i < n; i++) scanf("%d", &x), B[x - 1] = i;
  for (i = 0; i < n; i++) {
    res = ((int)1e9), id = -1, b = ((int)1e9);
    for (j = 0; 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;
    }
    printf("%d ", id + 1);
  }
  printf("\n");
  return 0;
}
