#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
const int inf = 0x3f3f3f3f;
const long long inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-5;
const int maxn = 303;
vector<int> have[maxn];
int in[maxn][maxn], al[maxn];
int num[maxn][maxn];
bool current[maxn];
int res[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> in[i][j];
      in[i][j]--;
      num[i][in[i][j]] = j;
    }
  for (int i = 0; i < n; i++) {
    cin >> al[i];
    al[i]--;
  }
  for (int i = 0; i < n; i++) {
    current[i] = true;
    for (int j = 0; j < n; j++)
      if (current[al[j]]) have[i].push_back(al[j]);
  }
  for (int i = 0; i < n; i++) {
    ;
    ;
    int best = n;
    for (int t = 0; t < n; t++) {
      for (int j = 0; j < (int((have[t]).size())); j++) {
        int val = have[t][j];
        ;
        ;
        ;
        if (val == i) continue;
        if (num[i][val] < best) {
          best = num[i][val];
          res[i] = t;
        }
        break;
      }
    };
  }
  for (int i = 0; i < n; i++) cout << res[i] + 1 << ' ';
  cout << endl;
  return 0;
}
