#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 310;
int t[N][N];
int a[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> t[i][j];
  for (int i = 1; i <= n; i++) cin >> a[i];
  set<pair<int, int> > v;
  for (int i = 1; i <= n; i++) {
    pair<int, int> gosc = {0, 0};
    for (int j = 1; j <= n; j++)
      if (a[j] <= i) {
        if (gosc.first) {
          gosc.second = a[j];
          break;
        } else
          gosc.first = a[j];
      }
    v.insert(gosc);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (t[i][j] == i) continue;
      auto pt = v.lower_bound({t[i][j], -inf});
      if (v.count({i, t[i][j]}) || (pt != v.end() && (*pt).first == t[i][j])) {
        cout << t[i][j] << ' ';
        break;
      }
    }
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
