#include <bits/stdc++.h>
using namespace std;
void loadData(void);
void proc(void);
void printRes(void);
int n;
int prefer[301][301];
const int INF = 1000000000;
int getMyPrefer(int start, int end, int aFriend);
int giveToFriend(int aFriend, int card);
bool lyb_debug = false;
int main(int argc, char** argv) {
  loadData();
  proc();
  return 0;
}
int giveToFriend(int aFriend, int card) {
  if (card == INF) return INF;
  int res = 1;
  for (; res <= n; res++) {
    if (prefer[aFriend][res] == card) break;
  }
  return res;
}
int getMyPrefer(int start, int end, int aFriend) {
  int res = 1;
  for (; res <= n; res++)
    if (prefer[0][res] <= end && prefer[0][res] != aFriend) break;
  return res == n + 1 ? INF : prefer[0][res];
}
void proc(void) {
  for (int i = 1; i <= n; i++) {
    int respos = 301;
    int res;
    for (int j = 1; j <= n; j++) {
      int preferest = getMyPrefer(1, j, i);
      int pos = giveToFriend(i, preferest);
      respos = min(respos, pos);
      if (pos == respos) res = preferest;
      if (lyb_debug) {
        printf("for frind %d: if to card %d:preferest:%d pos:%d res:%d\n", i, j,
               preferest, pos, res);
      }
    }
    if (lyb_debug) {
      printf("answer: ");
    }
    printf("%d%c", res, i == n ? '\n' : ' ');
    if (lyb_debug) {
      printf("\n");
    }
  }
  return;
}
void loadData(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &prefer[i][j]);
  for (int i = 1; i <= n; i++) scanf("%d", &prefer[0][i]);
  return;
}
void printRes(void) {
  printf("2 1 1 3\n");
  return;
}
