#include <bits/stdc++.h>
using namespace std;
int N;
int P[309][309];
int M[309];
int sol[309];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) scanf("%d", &P[i][j]);
  for (int i = 1; i <= N; i++) scanf("%d", &M[i]);
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      int V = P[i][j];
      if (V == i) continue;
      int minimum = 309;
      for (int k = 1; M[k] != V; k++)
        if (M[k] != i) minimum = min(minimum, M[k]);
      if (minimum > V) {
        sol[i] = V;
        break;
      }
    }
  }
  for (int i = 1; i <= N - 1; i++) printf("%d ", sol[i]);
  printf("%d\n", sol[N]);
  return 0;
}
