#include <bits/stdc++.h>
const int maxn = 310;
int n;
int pr[maxn][maxn];
int rpr[maxn][maxn];
int prh[maxn];
int rprh[maxn];
int rec[maxn];
int ans[maxn];
int getprh(int x) {
  for (int i = 1; i <= n; i++) {
    if (prh[i] == x) return i;
  }
  return 0;
}
int main() {
  memset(rec, 0, sizeof(rec));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &pr[i][j]);
      rpr[i][pr[i][j]] = j;
    }
  }
  for (int j = 1; j <= n; j++) {
    scanf("%d", &prh[j]);
    rprh[prh[j]] = j;
  }
  int sd = 0, psd = 0;
  for (int i = 1; i <= n; i++) {
    if (sd == 0 || getprh(i) < getprh(sd)) {
      sd = i;
    }
    psd = 0;
    for (int j = 1; j <= i; j++) {
      if (j == sd) continue;
      if (psd == 0 || rprh[psd] > rprh[j]) psd = j;
    }
    for (int j = 1; j <= n; j++) {
      int nsd = sd;
      if (j == sd) {
        if (i > 1)
          nsd = psd;
        else
          continue;
      }
      int t = rec[j];
      if (t == 0 || rpr[j][nsd] < t) {
        t = rpr[j][nsd];
        rec[j] = t;
        ans[j] = i;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d%c", ans[i], i == n ? '\n' : ' ');
  }
  return 0;
}
