#include <bits/stdc++.h>
using namespace std;
int a[312][312];
int pref[312];
int ans[312];
int find(int id, int n) {
  int place[312];
  int pos = 1;
  for (int i = 0; i < (n); ++i) place[a[id][i]] = pos++;
  int ans = 312, loc = -1;
  for (int i = 0; i < (n); ++i) {
    int cur = -1;
    for (int j = 0; j < (n); ++j)
      if (pref[j] <= i && pref[j] != id) {
        cur = pref[j];
        break;
      }
    if (cur != -1 && ans > place[cur]) {
      ans = place[cur];
      loc = cur;
    }
  }
  return loc + 1;
}
int main() {
  int n = ({
    int _x;
    scanf("%d", &_x);
    _x;
  });
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j)
      a[i][j] = ({
                  int _x;
                  scanf("%d", &_x);
                  _x;
                }) -
                1;
  for (int i = 0; i < (n); ++i)
    pref[i] = ({
                int _x;
                scanf("%d", &_x);
                _x;
              }) -
              1;
  for (int i = 0; i < (n); ++i) printf("%d ", find(i, n));
  printf("\n");
  return 0;
}
