#include <bits/stdc++.h>
using namespace std;
int pr[302][302];
int main() {
  int i, j, k, n, tmp, res, pos;
  while (cin >> n) {
    memset(pr, 0, sizeof(pr));
    for (i = 1; i <= n; i++) {
      for (j = 0; j < n; j++) {
        cin >> k;
        pr[i][k] = n - j;
      }
    }
    for (j = 0; j < n; j++) cin >> pr[0][j];
    for (i = 1; i <= n; i++) {
      res = -1;
      for (j = 1; j <= n; j++) {
        for (k = 0; k < n; k++) {
          if (pr[0][k] > j) continue;
          tmp = pr[0][k];
          if (tmp != i) {
            if (pr[i][tmp] > res) {
              res = pr[i][tmp];
              pos = j;
            }
            break;
          }
        }
      }
      if (i > 1) printf(" ");
      printf("%d", pos);
    }
    printf("\n");
  }
  return 0;
}
