#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const double EPS = 1E-9;
const double PI = acos((double)0) * 2;
const int MAXN = 310;
int n, a[MAXN][MAXN];
bool read() {
  if (!(cin >> n)) return false;
  for (int i = 0; i < int(n + 1); ++i)
    for (int j = 0; j < int(n); ++j) {
      scanf("%d", &a[i][j]);
      --a[i][j];
    }
  return true;
}
pair<int, int> mx[MAXN];
int find(int man, int card) {
  for (int i = 0; i < int(n); ++i)
    if (a[man][i] == card) return i;
  return INF;
}
void solve() {
  for (int i = 0; i < int(n); ++i) {
    mx[i] = i ? mx[i - 1] : make_pair(-1, -1);
    if (find(n, i) < find(n, mx[i].first)) {
      mx[i].second = mx[i].first;
      mx[i].first = i;
    } else if (find(n, i) < find(n, mx[i].second))
      mx[i].second = i;
  }
  for (int who = 0; who < int(n); ++who) {
    int sel = -1;
    for (int time = 0; time < int(n); ++time) {
      pair<int, int> cur = mx[time];
      if (cur.first != who) {
        if (find(who, cur.first) < find(who, sel)) sel = cur.first;
      } else if (find(who, cur.second) < find(who, sel))
        sel = cur.second;
    }
    printf("%d ", sel + 1);
  }
  puts("");
}
int main() {
  if (!read()) throw;
  solve();
}
