#include <bits/stdc++.h>
using namespace std;
int like[305][305];
int alex[305];
int f[305];
int n;
vector<int> vec;
void Init();
void Solve();
void Print();
bool comp(int a, int b) { return alex[a] < alex[b]; }
void Init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      like[i][x] = j;
    }
  }
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    alex[x] = i;
  }
  for (int i = 1; i <= n; i++) {
    f[i] = 0;
  }
}
void Solve() {
  for (int i = 1; i <= n; i++) {
    vec.push_back(i);
    sort(vec.begin(), vec.end(), comp);
    for (int j = 1; j <= n; j++) {
      for (int p = 0; p < vec.size(); p++) {
        if (vec[p] == j)
          continue;
        else if (like[j][f[j]] > like[j][vec[p]] or f[j] == 0) {
          f[j] = vec[p];
          break;
        } else
          break;
      }
    }
  }
}
void Print() {
  for (int i = 1; i <= n; i++) {
    printf("%d ", f[i]);
  }
  puts("");
}
int main() {
  Init();
  Solve();
  Print();
  return 0;
}
