#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
int al[10001];
pair<int, int> ans[10001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (n); j++) cin >> a[i][j];
    ans[i].first = 1e9;
  }
  for (int i = 1; i <= (n); i++) cin >> al[i];
  for (int t = 1; t <= (n); t++) {
    int t1 = 0, t2 = 0;
    for (int i = 1; i <= (n); i++) {
      if (t1 == 0 && al[i] <= t) {
        t1 = al[i];
        continue;
      }
      if (t1 != 0 && al[i] <= t) {
        t2 = al[i];
        break;
      }
    }
    for (int i = 1; i <= (n); i++)
      for (int j = 1; j <= (n); j++) {
        if (i != t1) {
          if (a[i][j] == t1)
            if (ans[i].first > j) {
              ans[i].first = j;
              ans[i].second = t1;
            }
        } else if (a[i][j] == t2)
          if (ans[i].first > j) {
            ans[i].first = j;
            ans[i].second = t2;
          }
      }
  }
  for (int i = 1; i <= (n); i++) cout << ans[i].second << ' ';
  return 0;
}
