#include <bits/stdc++.h>
using namespace std;
const int N = 333;
long long n, ans[N], a[N][N], pos[N];
long long absv(long long val) {
  if (val < 0) val *= -1;
  return val;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < n; j++) cin >> a[i][j];
  }
  for (int i = 0; i < n; i++) pos[i] = N;
  for (int i = 0; i < n; i++) {
    long long num = i + 1, num2 = i + 1, jx = 0;
    for (int j = 0; j < n; j++) {
      if (a[n][j] <= num) {
        num = a[n][j];
        jx = j;
        break;
      }
    }
    for (int j = jx + 1; j < n; j++) {
      if (a[n][j] <= num2) {
        num2 = a[n][j];
        break;
      }
    }
    for (int j = 0; j < n; j++) {
      long long tmp = num;
      if (j + 1 == num)
        if (num != num2)
          num = num2;
        else
          continue;
      for (int k = 0; k < n; k++) {
        if (a[j][k] == num)
          if (k < pos[j]) {
            pos[j] = k;
            ans[j] = i + 1;
          }
      }
      num = tmp;
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
