#include <bits/stdc++.h>
using namespace std;
const int maxn = 309;
int n, like[maxn][maxn], alex[maxn], res[maxn];
bool has[maxn] = {};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      like[i][x] = j;
    }
    like[i][i] = 9998;
    like[i][0] = 9999;
  }
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    alex[i] = x;
  }
  for (int i = 1; i <= n; i++) {
    has[i] = 1;
    int j = 1;
    for (j = 1; j <= n; j++)
      if (has[alex[j]]) break;
    for (int k = 1; k <= n; k++) {
      if (k == alex[j]) {
        for (int t = j + 1; t <= n; t++)
          if (has[alex[t]]) {
            if (like[k][alex[t]] < like[k][res[k]]) res[k] = alex[t];
            break;
          }
      } else if (like[k][alex[j]] < like[k][res[k]])
        res[k] = alex[j];
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", res[i]);
}
