#include <bits/stdc++.h>
#pragma hdrstop
using namespace std;
long long a[305][305], c[305][305], b[305], revb[305];
int main() {
  long long n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) cin >> a[i][j];
  for (i = 1; i <= n; i++) {
    cin >> b[i];
    revb[b[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    long long preo;
    for (j = 1; j <= n; j++) {
      if (j == 1)
        preo = 1;
      else if ((revb[preo] > revb[j] || preo == i) && j != i) {
        preo = j;
      }
      if (preo != i) c[i][preo] = 1;
    }
    for (j = 1; j <= n; j++)
      if (c[i][a[i][j]] == 1) {
        cout << a[i][j] << ' ';
        break;
      }
  }
  return 0;
}
