#include <bits/stdc++.h>
using namespace std;
const int maxn = 500000;
const long long inf = 10000000000000000LL;
const double eps = 1.0e-7;
int A[500][500];
int Al[500];
vector<int> Al2;
int mark[500];
int Ans[500][2];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) Ans[i][0] = Ans[i][1] = n + 1;
  for (int i = 1; i <= n; i++) {
    int t;
    for (int j = 1; j <= n; j++) {
      cin >> t;
      A[i][j] = t;
    }
  }
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    Al[i] = t;
  }
  for (int r = 1; r <= n; r++) {
    int ot = 0;
    int ot2 = 0;
    for (int i = 1; i <= n; i++) {
      if (ot == 0 && Al[i] <= r) {
        ot = Al[i];
      } else if (ot != 0 && Al[i] <= r) {
        ot2 = Al[i];
        break;
      }
    }
    for (int i = 1; i <= n; i++) {
      int found = ot;
      if (found == i) {
        found = ot2;
      }
      if (found == 0) continue;
      for (int pr = 1; pr <= n; pr++) {
        if (A[i][pr] == found) {
          if (Ans[i][0] > pr) {
            Ans[i][0] = pr;
            Ans[i][1] = r;
          }
          break;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << Ans[i][1] << " ";
  return 0;
}
