#include <bits/stdc++.h>
using namespace std;
int a[333][333];
int ans[333];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < n; j++) {
      int x;
      scanf("%d", &x);
      --x;
      a[i][x] = j;
    }
    a[i][i] = 1e9;
  }
  int m1 = -1, m2 = -1;
  fill(ans, ans + n, -1);
  for (int i = 0; i < n; i++) {
    if (m1 == -1 || a[n][i] < a[n][m1]) {
      m2 = m1;
      m1 = i;
    } else if (m2 == -1 || a[n][i] < a[n][m2]) {
      m2 = i;
    }
    for (int j = 0; j < n; j++) {
      int x = m1;
      if (x == j) {
        x = m2;
      }
      if (x == -1) {
        continue;
      }
      if (ans[j] == -1 || a[j][x] < a[j][ans[j]]) {
        ans[j] = x;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] + 1 << " ";
  }
  return 0;
}
