#include <bits/stdc++.h>
using namespace std;
const int MAX = 307;
int pos[MAX][MAX], send[MAX][MAX], like[MAX];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      int x;
      cin >> x;
      pos[i][x] = j;
    }
    pos[i][n + 1] = (int)1e8;
  }
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    like[x] = i;
  }
  like[n + 1] = (int)1e8;
  int a = n + 1, b = n + 1;
  for (int i = 1; i <= n; ++i) {
    if (like[i] < like[a]) {
      b = a;
      a = i;
    } else if (like[i] < like[b])
      b = i;
    for (int j = 1; j <= n; ++j) {
      if (j != a)
        send[j][i] = a;
      else
        send[j][i] = b;
    }
  }
  for (int i = 1; i <= n; ++i) {
    int mx = n;
    for (int j = 1; j <= n; ++j) {
      if (pos[i][send[i][j]] < pos[i][send[i][mx]]) mx = j;
    }
    cout << mx << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
