#include <bits/stdc++.h>
using namespace std;
const long double epsylon = 1e-9;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > a(n);
  for (int i = 0; i < n; ++i) {
    a[i].resize(n);
    for (int j = 0; j < n; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  vector<int> pr(n + 1);
  for (int i = 0; i < n; ++i) {
    pr[b[i]] = i;
  }
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == i + 1) {
        continue;
      }
      bool can = true;
      for (int k = j + 1; k < n; ++k) {
        if (a[i][k] < a[i][j] && pr[a[i][k]] < pr[a[i][j]] &&
            a[i][k] != i + 1) {
          can = false;
          break;
        }
      }
      if (can) {
        ans[i] = a[i][j];
        break;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", ans[i], ((i + 1 == n) ? '\n' : ' '));
  }
  return 0;
}
