#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int g[300][300];
int q[300], res[300], pos[300];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    for (int j = 0; j < n; j++) {
      scanf("%d", &x);
      x--;
      g[i][x] = j;
    }
  }
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    x--;
    q[x] = i;
  }
  for (int i = 0; i < n; i++) {
    res[i] = -1;
    pos[i] = -1;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      int cur = -1;
      for (int k = 0; k <= i; k++)
        if (k != j && (cur == -1 || q[cur] > q[k])) cur = k;
      if (cur == -1) continue;
      if (pos[j] == -1 || g[j][pos[j]] > g[j][cur]) {
        res[j] = i;
        pos[j] = cur;
      }
    }
  for (int i = 0; i < n; i++) printf("%d ", res[i] + 1);
  printf("\n");
  return 0;
}
