#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, qian, k;
  int a[305][305], karry[305], ans[305], s[305][2];
  while (~scanf("%d", &n)) {
    memset(ans, 0, sizeof(ans));
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        scanf("%d", &a[i][j]);
      }
    }
    for (i = 1; i <= n; i++) scanf("%d", &karry[i]);
    for (i = 1; i <= n; i++) {
      qian = 0;
      for (j = 1; j <= n; j++) {
        if (i >= karry[j]) {
          s[i][qian++] = karry[j];
          if (qian == 2) {
            break;
          }
        }
      }
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        if (a[i][j] != i) {
          for (k = 1; k <= n; k++) {
            if (s[k][0] == i && s[k][1] == a[i][j]) {
              ans[i] = s[k][1];
              break;
            } else if (s[k][0] == a[i][j]) {
              ans[i] = s[k][0];
              break;
            }
          }
          if (k <= n) break;
        }
      }
    }
    for (i = 1; i <= n; i++) {
      printf("%d", ans[i]);
      if (i == n)
        printf("\n");
      else
        printf(" ");
    }
  }
  return 0;
}
