#include <bits/stdc++.h>
using namespace std;
int ar[306][306], val[301], ans[301];
int main() {
  int n, i, j, k;
  cin >> n;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) cin >> ar[i][j];
  for (i = 0; i < n; i++) cin >> val[i];
  for (i = 0; i < n; i++) {
    int f = 1;
    for (j = 0; j < n && f; j++)
      if (ar[i][j] != i + 1) {
        int f1 = 0;
        for (k = 0; k < n && val[k] != ar[i][j]; k++)
          if (val[k] != i + 1 && val[k] < ar[i][j]) f1 = 1;
        if (f1 == 0) {
          f = 0;
          cout << ar[i][j] << " ";
        }
      }
  }
  cout << endl;
}
