#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1), eps = 1e-5;
const int maxn = 512;
int weight[maxn];
int matrix[maxn][maxn];
int first[maxn], second[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &matrix[i][j]);
  for (int i = 1; i <= n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    weight[tmp] = n - i + 1;
  }
  first[1] = 1;
  second[1] = -1;
  if (weight[1] < weight[2]) {
    first[2] = 2;
    second[2] = 1;
  } else {
    first[2] = 1;
    second[2] = 2;
  }
  for (int i = 3; i <= n; ++i) {
    if (weight[i] > weight[first[i - 1]]) {
      first[i] = i;
      second[i] = first[i - 1];
    } else if (weight[i] > weight[second[i - 1]]) {
      first[i] = first[i - 1];
      second[i] = i;
    } else {
      first[i] = first[i - 1];
      second[i] = second[i - 1];
    }
  }
  int ans[maxn];
  for (int i = 1; i <= n; ++i) {
    bool flag = true;
    for (int j = 1; j <= n && flag; ++j) {
      if (matrix[i][j] != i) {
        for (int k = 1; k <= n; ++k) {
          if (first[k] == matrix[i][j] ||
              first[k] == i && second[k] == matrix[i][j]) {
            ans[i] = k;
            flag = false;
            break;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << " ";
  }
}
