#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
inline int getint() {
  int x;
  scanf("%d", &x);
  return x;
}
int data[512][512];
int me[512];
int ans[512];
int best[512];
int n;
inline bool ok(int x, int forb) {
  if (x == forb) return false;
  int minv = INF;
  for (int i = 0, _n = (n); i < _n; ++i) {
    if (me[i] == forb) continue;
    minv = min(minv, me[i]);
    if (me[i] == x) break;
  }
  return x == minv;
}
int main() {
  n = getint();
  for (int i = 0, _n = (n); i < _n; ++i)
    for (int j = 0, _n = (n); j < _n; ++j) data[i][j] = getint() - 1;
  for (int i = 0, _n = (n); i < _n; ++i) me[i] = getint() - 1;
  for (int i = 0, _n = (n); i < _n; ++i)
    for (int j = 0, _n = (n); j < _n; ++j)
      if (ok(data[i][j], i)) {
        best[i] = data[i][j];
        break;
      }
  for (int i = 0, _n = (n); i < _n; ++i) {
    for (int j = 0, _n = (n); j < _n; ++j)
      if (best[j] == i) {
        ans[j] = i;
      }
  }
  for (int i = 0, _n = (n); i < _n; ++i) {
    if (i) printf(" ");
    printf("%d", ans[i] + 1);
  }
  puts("");
  return 0;
}
