#include <bits/stdc++.h>
using namespace std;
int a[512][512], b[512], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", a[i] + j);
  for (int i = 1; i <= n; ++i) scanf("%d", b + i);
  for (int i = 1; i <= n; ++i) {
    int t = 0, s = 1000, h = 0, jj;
    for (int j = 1; j <= n; ++j)
      if (j != i) {
        for (int k = 1; k <= n; ++k)
          if (b[k] <= j && b[k] != i) {
            t = b[k];
            break;
          }
        for (int k = 1; k <= n; ++k)
          if (a[i][k] == t) {
            h = k;
            break;
          }
        if (h < s) {
          s = h;
          jj = j;
        }
      }
    printf("%d ", jj);
  }
  return 0;
}
