#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, n, flag, ans[400];
  int a[400][400], G[400][400];
  cin >> n;
  for (i = 1; i <= n + 1; i++)
    for (j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      for (k = 1; k <= n; k++) {
        if (a[n + 1][k] <= j && a[n + 1][k] != i) {
          G[i][j] = a[n + 1][k];
          break;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      flag = 0;
      if (a[i][j] == i) continue;
      for (k = 1; k <= n; k++)
        if (G[i][k] == a[i][j]) {
          flag = 1;
          ans[i] = G[i][k];
          break;
        }
      if (flag) break;
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%d", ans[i]);
    printf("%c", i != n ? ' ' : '\n');
  }
}
