#include <bits/stdc++.h>
using namespace std;
int prep[300][300];
int my_prev[300];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &prep[i][j]);
  for (int i = 0; i < n; i++) scanf("%d", &my_prev[i]);
  int my_prev_pos[301] = {0};
  for (int i = 0; i < n; i++) my_prev_pos[my_prev[i]] = i;
  int res[300] = {0};
  for (int i = 0; i < n; i++) {
    int opp_pos[301] = {0};
    for (int j = 0; j < n; j++) opp_pos[prep[i][j]] = j;
    int best_pos = 999;
    int best_num = 999;
    int opp_best_pos = 999;
    int opp_best_num = 999;
    for (int j = 1; j <= n; j++) {
      if (i + 1 == j) continue;
      if (my_prev_pos[j] < best_pos) {
        best_pos = my_prev_pos[j];
        best_num = j;
        if (opp_pos[best_num] < opp_best_pos) {
          opp_best_pos = opp_pos[best_num];
          opp_best_num = best_num;
        }
      }
    }
    res[i] = opp_best_num;
  }
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
