#include <bits/stdc++.h>
using namespace std;
int n, m;
bool debug = false;
int k, ans;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
vector<int> f[345];
int me[345], fme[345];
bool ck(int p, int i) {
  for (int j = 1; j < i; j++)
    if (j != p) {
      if (fme[j] < fme[i]) return 0;
    }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &m);
      if (m != i) f[i].push_back(m);
    }
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", me + i);
    fme[me[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    int ans = f[i].back();
    for (int j = 0; j < n - 1; j++) {
      if (ck(i, f[i][j])) {
        ans = f[i][j];
        break;
      }
    }
    printf("%d ", ans);
  }
  return 0;
}
