#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a[300][300];
  int b[300];
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    int cur = -1;
    int w = -1;
    int res = 1000;
    int q;
    for (int j = 0; j < n; j++)
      if (j != i) {
        for (int k = 0; k < n; k++)
          if (b[k] == j + 1)
            if ((k < w || w == -1)) {
              cur = j + 1;
              w = k;
              break;
            } else
              break;
        for (int k = 0; k < n; k++)
          if (cur == a[i][k])
            if (k < res) {
              res = k;
              q = cur;
              break;
            } else
              break;
      }
    cout << q << ' ';
  }
  return 0;
}
