#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int a[500][500], b[500], can[500];
int main() {
  int N, i, j, x;
  cin >> N;
  memset(a, 0x7f, sizeof(a));
  memset(b, 0x7f, sizeof(b));
  for (i = 1; i <= N; i++)
    for (j = 1; j <= N; j++) {
      cin >> x;
      a[i][x] = j;
    }
  for (i = 1; i <= N; i++) {
    cin >> x;
    b[x] = i;
  }
  for (i = 1; i <= N; i++) {
    int p = 0, now = 0;
    for (j = 1; j <= N; j++) {
      if (j != i && b[j] < b[now]) now = j;
      if (a[i][now] < a[i][p]) p = now;
    }
    cout << p << ' ';
  }
}
