#include <bits/stdc++.h>
using namespace std;
int n, p[310][310], cur, pre, best[310], ans[310];
bool f[310];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int X;
      scanf("%d", &X);
      p[i][X] = j;
    }
  for (int j = 1; j <= n; j++) {
    int X;
    scanf("%d", &X);
    p[0][X] = j;
  }
  fill(best, best + n + 2, 310);
  cur = 1;
  pre = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = true;
    if (p[0][i] < p[0][cur]) {
      cur = i;
    }
    pre = 0;
    for (int j = 1; j <= n; j++)
      if (f[j] && j != cur && (pre == 0 || p[0][j] < p[0][pre])) pre = j;
    for (int j = 1; j <= n; j++)
      if (cur != j) {
        if (best[j] > p[j][cur]) {
          best[j] = p[j][cur];
          ans[j] = i;
        }
      } else {
        if (best[j] > p[j][pre] && pre != 0) {
          best[j] = p[j][pre];
          ans[j] = i;
        }
      }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
