#include <bits/stdc++.h>
int main() {
  int N;
  scanf("%d", &N);
  static int data[305];
  static int a[305][305];
  int i, j;
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      scanf("%d", &(a[i][j]));
      (a[i][j])--;
    }
  }
  for (j = 0; j < N; j++) {
    scanf("%d", &(data[j]));
    (data[j])--;
  }
  static char b[305];
  int q;
  for (q = 0; q < N; q++) {
    memset(b, 0, sizeof(b));
    int prevpos = N;
    int min, minpos;
    while (1) {
      min = N;
      minpos = -1;
      for (i = 0; i < prevpos; i++) {
        if ((data[i] < min) && (data[i] != q)) {
          min = data[i];
          minpos = i;
        }
      }
      if (minpos == -1) break;
      b[min] = 1;
      prevpos = minpos;
    }
    j = 0;
    while (!b[a[q][j]]) j++;
    if (q) printf(" ");
    printf("%d", a[q][j] + 1);
  }
  printf("\n");
  return 0;
}
