#include <bits/stdc++.h>
const int N = 305;
int n;
int a[N][N];
int b[N];
int c[N];
int ok[N];
int ans[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d ", &a[i][j]);
      a[i][j]--;
    }
  for (int j = 0; j < n; j++) {
    scanf("%d ", &b[j]);
    b[j]--;
  }
  for (int i = 0; i < n; i++) c[b[i]] = i;
  for (int i = 0; i < n; i++) {
    ok[b[i]] = 0;
    for (int j = 0; j < i; j++)
      if (b[j] < b[i]) ok[b[i]]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (a[i][j] != i &&
          (ok[a[i][j]] == 0 ||
           ok[a[i][j]] == 1 && c[i] < c[a[i][j]] && i < a[i][j])) {
        ans[i] = a[i][j];
        break;
      }
  }
  for (int i = 0; i < n; i++)
    printf("%d%c", ans[i] + 1, i + 1 == n ? '\n' : ' ');
  return 0;
}
