#include <bits/stdc++.h>
using namespace std;
int graph[310][310];
int answer[310];
int main() {
  int n;
  scanf("%d", &n);
  int s;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &s);
      graph[i][s] = j;
    }
  for (int j = 1; j <= n; j++) {
    scanf("%d", &s);
    graph[0][s] = j;
  }
  int first, second;
  for (int i = 3; i <= n; i++) answer[i] = 1;
  if (graph[0][2] < graph[0][1]) {
    for (int i = 3; i <= n; i++)
      if (graph[i][2] < graph[i][1]) answer[i] = 2;
  }
  answer[1] = 2;
  answer[2] = 1;
  if (graph[0][1] < graph[0][2])
    first = 1, second = 2;
  else
    first = 2, second = 1;
  for (int i = 3; i <= n; i++) {
    if (graph[0][i] < graph[0][first]) {
      second = first;
      first = i;
    } else if (graph[0][i] < graph[0][second])
      second = i;
    for (int j = 1; j <= n; j++) {
      if (first == j) {
        if (graph[j][second] < graph[j][answer[j]]) answer[j] = second;
      } else {
        if (graph[j][first] < graph[j][answer[j]]) answer[j] = first;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", answer[i]);
  return 0;
}
