#include <bits/stdc++.h>
using namespace std;
const int N = 305;
int i, j, k, l;
int n, a[N][N], b[N], c[N], d[N], e[N];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) scanf("%d", &k), a[i][k] = n + 1 - j;
  for (i = 1; i <= n; i++) scanf("%d", &k), b[k] = n + 1 - i, c[i] = d[i] = 0;
  k = l = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      l = 0;
      for (k = 1; k <= i; k++)
        if (k != j && b[k] > b[l]) l = k;
      if (l == 0) continue;
      if (d[j] == 0 || a[j][d[j]] < a[j][l]) {
        d[j] = l;
        e[j] = i;
      }
    }
  }
  for (i = 1; i < n; i++) printf("%d ", e[i]);
  printf("%d\n", e[n]);
}
