#include <bits/stdc++.h>
using namespace std;
int n;
int mp[400][400];
int q[400];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &mp[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    int tmp;
    scanf("%d", &tmp);
    q[tmp] = i;
  }
  for (int i = 1; i <= n; i++) {
    int a;
    int w;
    for (int j = 1; j <= n; j++) {
      if (mp[i][j] == i) continue;
      w = q[mp[i][j]];
      a = 1;
      for (int k = 1; k < mp[i][j]; k++) {
        if (k == i) continue;
        if (q[k] < w) {
          a = 0;
          break;
        }
      }
      if (a) {
        printf("%d ", mp[i][j]);
        break;
      }
    }
  }
}
