#include <bits/stdc++.h>
using namespace std;
FILE* g_f_;
int g_s_;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int n;
int a[1024][1024];
int b[1024];
int c[1024][2];
int r[1024];
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  (g_s_ = scanf("%d", &n));
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      (g_s_ = scanf("%d", &a[i][j]));
      a[i][j]--;
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    (g_s_ = scanf("%d", &b[i]));
    b[i]--;
    r[b[i]] = i;
  }
  int m1 = -1, m2 = -1;
  for (int i = 0; i < (int)(n); i++) {
    if (m1 == -1)
      m1 = i;
    else if (m2 == -1) {
      m2 = i;
      if (r[m1] > r[m2]) swap(m1, m2);
    } else {
      if (r[m1] > r[i]) {
        m2 = m1;
        m1 = i;
      } else if (r[m2] > r[i]) {
        m2 = i;
      }
    }
    c[i][0] = m1;
    c[i][1] = m2;
  }
  for (int i = 0; i < (int)(n); i++) {
    int ans = -1;
    bool bb = false;
    for (int k = 0; k < (int)(n); k++) {
      for (int j = 0; j < (int)(n); j++) {
        if ((c[j][0] == a[i][k] && c[j][0] != i) ||
            (c[j][1] == a[i][k] && c[j][0] == i)) {
          ans = j;
          bb = true;
          break;
        }
      }
      if (bb) break;
    }
    printf("%d%c", ans + 1, " \n"[i == n - 1]);
  }
  return 0;
}
