#include <bits/stdc++.h>
using namespace std;
int n;
int p[310][310];
int pr[310];
int a[310];
bool best(int x, int y) {
  for (int i = 0; i < n; i++) {
    if (p[y][i] == y) continue;
    if (p[y][i] == x) return true;
    int temp = p[y][i];
    if (pr[temp] < pr[x]) return false;
  }
  return true;
}
int solve(int x) {
  int i = 0;
  for (i = 0; i < n; i++) {
    int temp = p[x][i];
    if (p[x][i] != x) {
      int j = i + 1;
      for (; j < n; j++)
        if (p[x][j] != x && p[x][j] < temp && pr[p[x][j]] < pr[temp]) break;
      if (j == n) return temp + 1;
    }
  }
  return n;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &p[i][j]);
      p[i][j]--;
    }
  int x;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    pr[x - 1] = i;
  }
  for (int i = 0; i < n; i++) a[i] = solve(i);
  for (int i = 0; i < n - 1; i++) printf("%d ", a[i]);
  printf("%d\n", a[n - 1]);
  return 0;
}
