#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, k, a[111111], b[555], d[333][333];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      cin >> k;
      d[i][k] = j;
    }
  for (i = 1; i <= n; i++) {
    cin >> d[0][i];
  }
  for (i = 1; i <= n; i++) {
    int t;
    k = 555;
    t = n + 1;
    for (j = 1; j <= n; j++)
      if (d[0][j] < k && d[0][j] != i) {
        k = d[0][j];
        if (d[i][k] < t) {
          t = d[i][k];
          a[i] = k;
        }
      }
  }
  for (i = 1; i <= n; i++) cout << a[i] << ' ';
}
