#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int i, j;
    int grid[350][350], qGrid[350][350];
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) scanf("%d", &grid[i][j]);
    }
    int alex[350];
    for (i = 1; i <= n; i++) {
      scanf("%d", &alex[i]);
    }
    for (i = 1; i <= n; i++) {
      int first = 1, second = 1, flag = 0;
      for (j = 1; j <= n; j++) {
        if (flag == 0 && alex[j] >= 1 && alex[j] <= i)
          first = alex[j], flag = 1;
        else if (alex[j] >= 1 && alex[j] <= i) {
          second = alex[j];
          break;
        }
      }
      for (j = 1; j <= n; j++) {
        if (first == j && second == j)
          qGrid[i][j] = 0;
        else if (first == j)
          qGrid[i][j] = second;
        else if (first != j)
          qGrid[i][j] = first;
      }
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        int flag = 0;
        for (int k = 1; k <= n; k++) {
          if (grid[i][j] == qGrid[k][i]) {
            printf("%d", k), printf(" ");
            flag = 1;
            break;
          }
        }
        if (flag == 1) break;
      }
    }
    printf("\n");
  }
  return 0;
}
