#include <bits/stdc++.h>
using namespace std;
const int Inf = 0x3f3f3f3f;
int N, fav[303][303], pfav[303], choose[303][303], pr[303];
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j) {
      cin >> fav[i][j];
      --fav[i][j];
    }
  for (int i = 0; i < N; ++i) {
    cin >> pfav[i];
    --pfav[i];
  }
  for (int i = 0; i < N; ++i) pr[pfav[i]] = i;
  pr[N] = Inf;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      int c = N;
      for (int k = 0; k <= i; ++k)
        if (k != j && pr[k] < pr[c]) c = k;
      choose[j][i] = c;
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) pr[fav[i][j]] = j;
    pr[N] = Inf;
    int t = 0;
    for (int j = 0; j < N; ++j)
      if (pr[choose[i][j]] < pr[choose[i][t]]) t = choose[i][j];
    cout << t + 1 << " ";
  }
  return 0;
}
