#include <bits/stdc++.h>
using namespace std;
const int N = 305;
int n, a[N][N], b[N], p[N][N], q[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      p[i][a[i][j]] = j;
    }
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    q[b[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    int best = n + 1, idx;
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      int f = 1;
      for (int k = 1; k < j; k++) {
        if (i == k) continue;
        if (p[i][k] > p[i][j] && q[k] < q[j]) {
          f = 0;
          break;
        }
      }
      if (f) {
        if (p[i][j] < best) {
          best = p[i][j];
          idx = j;
        }
      }
    }
    cout << idx << endl;
  }
  return 0;
}
