#include <bits/stdc++.h>
int wei[310], p[310], r[310], ans[310];
int a[310][310], r2[310][310];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        scanf("%d", &a[i][j]);
        r2[i][a[i][j]] = j;
      }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &p[i]);
      r[p[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
      int now = -1, chose;
      memset(wei, -1, sizeof(wei));
      for (int j = 1; j <= n; j++) {
        if (i == j) continue;
        if (now == -1 || r[j] < now) {
          now = r[j];
          chose = j;
        }
        wei[j] = r2[i][chose];
      }
      ans[i] = i;
      for (int j = 1; j <= n; j++) {
        if (wei[j] == -1) continue;
        if (wei[ans[i]] == -1 || wei[j] < wei[ans[i]]) ans[i] = j;
      }
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
