#include <bits/stdc++.h>
using namespace std;
int a[300][300], n;
map<int, int> al;
int solve(vector<int> &x, int q) {
  int ind = -1;
  for (int i = 0; i < x.size(); i++)
    if (ind == -1 || al[x[ind]] > al[x[i]]) ind = i;
  if (ind == -1) return 1e9;
  for (int i = 0; i < n; i++)
    if (a[q][i] == x[ind]) return i;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    al[x] = i;
  };
  for (int i = 0; i < n; i++) {
    int kol = 1e9, ans = 0;
    for (int j = 1; j <= n; j++) {
      vector<int> cur;
      for (int k = 1; k <= j; k++)
        if (k != i + 1) cur.push_back(k);
      int y = solve(cur, i);
      if (cur.size() > 0 && y < kol) {
        ans = j;
        kol = y;
      }
    }
    cout << ans << " ";
  }
}
