#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
int n, best[500][500], val, myself[500], ans[500];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &val);
      best[i][val] = j;
    }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val);
    myself[val] = i;
  }
  myself[0] = n + 1;
  for (int q = 1; q <= n; q++) {
    int b = n + 1;
    for (int i = 1; i <= n; i++) {
      int bestval = 0;
      for (int j = 1; j <= i; j++)
        if (myself[j] < myself[bestval] && j != q) bestval = j;
      if (bestval != 0 && best[q][bestval] < b) {
        b = best[q][bestval];
        ans[q] = bestval;
      };
    };
  };
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
