#include <bits/stdc++.h>
using namespace std;
void task();
int main() {
  srand(time(0));
  task();
  return 0;
}
const int INF = 0x3f3f3f3f;
const int N = 310;
const int M = 1e5 + 10;
int n;
int a[N][N];
int b[N];
int ans[N];
void task() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  for (int i = 0; i < n; ++i) {
    int mx = 0;
    for (int step = 1; step <= n; ++step) {
      int val = 0;
      for (int j = 0; j < n; ++j)
        if (b[j] <= step && b[j] != i + 1) {
          val = b[j];
          break;
        }
      for (int j = 0; j < n; ++j)
        if (a[i][j] == val) {
          if (n - j > mx) {
            ans[i] = step;
            mx = n - j;
          }
          break;
        }
    }
  }
  for (int i = 0; i < n; ++i) printf("%d ", ans[i]);
}
