#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > likes(n, vector<int>(n, 0));
  vector<int> melikes(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int no;
      cin >> no;
      no--;
      likes[i][no] = n - j;
    }
    likes[i][i] = 0;
  }
  for (int j = 0; j < n; j++) {
    int no;
    cin >> no;
    no--;
    melikes[no] = n - j;
  }
  vector<pair<int, int> > cards;
  for (int i = 0; i < n; i++) {
    cards.clear();
    int bestNo = -1, bestPrice = 0;
    for (int no = 0; no < n; no++) {
      if (no == i) continue;
      cards.push_back(pair<int, int>(melikes[no], no));
      push_heap((cards).begin(), (cards).end());
      int price = likes[i][cards[0].second];
      if (bestNo == -1 || price > bestPrice) {
        bestNo = no;
        bestPrice = price;
      }
    }
    cout << ((i == 0) ? "" : " ") << (bestNo + 1);
  }
  cout << endl;
  return 0;
}
