#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > b(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      int x;
      cin >> x;
      --x;
      b[i][x] = j;
    }
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    --x;
    a[x] = i;
  }
  for (int i = 0; i < n; ++i) {
    vector<pair<int, int> > res;
    int k = -1;
    int val = 0;
    for (int j = 0; j < n; ++j) {
      res.push_back(make_pair(a[j], j));
      int x = -1;
      for (int l = 0; l < ((int)res.size()); ++l)
        if (x == -1 || res[x].first > res[l].first) x = l;
      if (res[x].second != i) {
        if (k == -1 || k > b[i][res[x].second]) {
          k = b[i][res[x].second];
          val = j;
        }
      } else {
        int x = -1;
        for (int l = 0; l < ((int)res.size()); ++l)
          if (res[l].second != i)
            if (x == -1 || res[x].first > res[l].first) x = l;
        if (x != -1)
          if (k == -1 || k > b[i][res[x].second]) {
            k = b[i][res[x].second];
            val = j;
          }
      }
    }
    cout << val + 1 << " ";
  }
  cout << endl;
  return 0;
}
