#include <bits/stdc++.h>
using namespace std;
int X[301][300];
int main(void) {
  int i, j, k, n;
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 0; j < n; j++) cin >> X[i][j];
  for (j = 0; j < n; j++) cin >> X[0][j];
  for (i = 1; i <= n; i++) {
    for (j = 0; true; j++)
      if (X[i][j] != i) {
        for (k = 0; X[0][k] > X[i][j] || X[0][k] == i; k++)
          ;
        if (X[0][k] == X[i][j]) break;
      }
    cout << X[i][j] << " ";
  }
  return 0;
}
