#include <bits/stdc++.h>
using namespace std;
int b1[310], b2[310], a[310][310], p[310];
int main() {
  int i, j, k, l, n;
  for (scanf("%d", &n), i = 0; i < n; i++)
    for (j = 0; j < n; scanf("%d", &k), k--, a[i][k] = j, j++)
      ;
  for (i = 0; i < n; scanf("%d", &k), k--, p[k] = i, i++)
    ;
  for (b1[0] = -1, b2[0] = -1, i = 0; i < n;
       b1[i + 1] = b1[i], b2[i + 1] = b2[i], i++)
    if (b1[i] == -1 || p[i] < p[b1[i]]) {
      b2[i] = b1[i];
      b1[i] = i;
    } else if (b2[i] == -1 || p[i] < p[b2[i]])
      b2[i] = i;
  for (i = 0; i < n; printf("%d%c", l + 1, i < n - 1 ? ' ' : '\n'), i++)
    for (k = -1, j = 0; j < n; j++)
      if (b1[j] != i) {
        if (k == -1 || a[i][b1[j]] < a[i][k]) {
          k = b1[j];
          l = j;
        }
      } else if (b2[j] != -1) {
        if (k == -1 || a[i][b2[j]] < a[i][k]) {
          k = b2[j];
          l = j;
        }
      }
  return 0;
}
