#include <bits/stdc++.h>
using namespace std;
int fav[1111], app[1111], a[1111][1111], poss[1111][1111];
int ans[1111], n;
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &a[i][j]);
      poss[i][a[i][j]] = j;
    }
  }
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    fav[x] = i;
  }
}
int vis[1111];
void solve() {
  for (int i = 1; i <= n; ++i) {
    for (int p = 1; p <= n; ++p) {
      int t = -1;
      for (int j = 1; j <= i; ++j)
        if (j != p) {
          if (t == -1) t = j;
          if (fav[j] < fav[t]) t = j;
        }
      if (t != -1) {
        if (ans[p] == 0) ans[p] = t;
        if (poss[p][t] < poss[p][ans[p]]) ans[p] = t;
      }
    }
  }
}
void print() {
  for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], i == n ? '\n' : ' ');
}
int main() {
  init();
  solve();
  print();
  return 0;
}
