#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  int a[400][400];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%d", &a[i][j]);
      a[i][j]--;
    }
  }
  int b[500];
  int w[301] = {};
  for (int i = 0; i < N; i++) {
    scanf("%d", &b[i]);
    b[i]--;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a[i][j] == i) continue;
      for (int k = 0; k < N; k++) {
        if (b[k] == i) continue;
        if (a[i][j] == b[k]) {
          printf("%d ", a[i][j] + 1);
          goto e1;
        }
        if (b[k] < a[i][j]) break;
      }
    }
  e1:;
  }
  return 0;
}
