#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-9;
const int INF = 101e7;
template <class T>
T sqr(T first) {
  return first * first;
}
template <class T>
T abs(T first) {
  return (first < 0) ? -first : first;
}
int a[320][320];
vector<int> p;
int main() {
  int n;
  cin >> n;
  for (int _b = (n), i = (1); i <= _b; i++)
    for (int _b = (n), j = (1); j <= _b; j++) cin >> a[i][j];
  p.resize(n + 1, 0);
  for (int _b = (n), i = (1); i <= _b; i++) cin >> p[i];
  vector<int> s(n + 1, 0);
  vector<int> pr(n + 1, 0);
  for (int _b = (n), i = (1); i <= _b; i++) {
    pr[p[i]] = i;
  }
  for (int _b = (n), k = (1); k <= _b; k++) {
    int beststep = 0, bestval = n + 1;
    int t1 = 0, pt1 = n + 1, t2 = 0, pt2 = n + 1;
    for (int _b = (n), i = (1); i <= _b; i++) {
      if (i == k) continue;
      if (pr[i] < pt2) {
        t2 = i;
        pt2 = pr[i];
      }
      if (pt1 > pt2) {
        swap(t1, t2);
        swap(pt1, pt2);
      }
      int q = 0;
      for (int _b = (n), j = (1); j <= _b; j++) {
        if (a[k][j] == t1) {
          q = j;
          break;
        }
      }
      if (q < bestval) {
        beststep = i;
        bestval = q;
      }
    }
    s[k] = beststep;
  }
  for (int _b = (n - 1), i = (1); i <= _b; i++) {
    printf("%d ", s[i]);
  }
  printf("%d\n", s[n]);
  return 0;
}
