#include <bits/stdc++.h>
using namespace std;
int n, arr[301][301], p[301], result[301];
int calc_value(int f, int idx) {
  if (idx == 0 && f == 0) return 5000;
  int choice = -1;
  for (int i = 0; i < n; i++)
    if (p[i] <= idx && p[i] != f) {
      choice = p[i];
      break;
    }
  for (int i = 0; i < n; i++)
    if (arr[f][i] == choice) {
      return i;
    }
  return 5000;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
      arr[i][j]--;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    int best = -1, value = 5000;
    for (int j = 0; j < n; j++) {
      int w = calc_value(i, j);
      if (w < value) {
        best = j;
        value = w;
      }
    }
    result[i] = best + 1;
  }
  for (int i = 0; i < n; i++) {
    cout << result[i] << " ";
  }
  cout << endl;
  return 0;
}
