#include <bits/stdc++.h>
int prefs[300][300];
int myprefs[300];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &prefs[i][j]);
    }
  }
  for (int i = 0; i < n; i++) scanf("%d", &myprefs[i]);
  char *sep = "";
  for (int i = 0; i < n; i++) {
    int use = 0;
    for (int j = 0; j < n; j++) {
      if (prefs[i][j] == i + 1) continue;
      int cando = 1;
      for (int k = 0; k < n; k++) {
        if (myprefs[k] == prefs[i][j]) break;
        if (myprefs[k] != i + 1 && myprefs[k] < prefs[i][j]) {
          cando = 0;
          break;
        }
      }
      if (cando) {
        use = prefs[i][j];
        break;
      }
    }
    printf("%s%d", sep, use);
    sep = " ";
  }
  printf("\n");
  return 0;
}
