#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll inf = 2e18;
const int mod = 1e9 + 7;
const ld eps = 1e-9;
const ld pi = 3.14159265358979323846;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(12);
  cout << fixed;
  int n;
  cin >> n;
  vector<vector<int>> a(n + 1, vector<int>(n));
  for (auto& i : a)
    for (auto& j : i) cin >> j, --j;
  vector<vector<int>> ind(n + 1, vector<int>(n));
  for (int i = 0; i < n + 1; ++i)
    for (int j = 0; j < n; ++j) {
      ind[i][a[i][j]] = j;
    }
  auto& me = ind[n];
  pair<int, int> g = {0, 0};
  vector<vector<int>> b(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    if (me[i] < me[g.first]) {
      swap(g.first, g.second);
      g.first = i;
    } else if (me[i] < me[g.second] || i == 1) {
      g.second = i;
    }
    for (int j = 0; j < n; ++j) {
      if (g.first != j) {
        b[j][ind[j][g.first]] = i + 1;
      } else if (g.second != j) {
        b[j][ind[j][g.second]] = i + 1;
      }
    }
  }
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (b[i][j]) {
        ans[i] = b[i][j];
        break;
      }
    }
  }
  for (auto i : ans) cout << i << " ";
  cout << endl;
  return 0;
}
