#include <bits/stdc++.h>
using namespace std;
int pref[310][310], card[300], arr[310], sent[310], mypref[310],
    thpref[310][310];
int main() {
  int n, temp, a, b;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; ++j) {
      cin >> pref[i][j];
      thpref[i][pref[i][j]] = j;
    }
  }
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    mypref[arr[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    sent[i] = -1;
  }
  for (int i = 1; i <= n; ++i) {
    int a = -1, b = -1, p1 = n + 1, p2 = n + 2;
    for (int j = 1; j <= i; j++) {
      if (mypref[j] < p1) {
        p1 = mypref[j];
        a = j;
      }
    }
    for (int j = 1; j <= i; ++j) {
      if (mypref[j] < p2 && mypref[j] != p1) {
        p2 = mypref[j];
        b = j;
      }
    }
    for (int j = 1; j <= n; j++) {
      if (a != j) {
        if (sent[j] == -1) sent[j] = a;
        if (thpref[j][sent[j]] > thpref[j][a]) {
          sent[j] = a;
        }
      } else {
        if (sent[j] == -1) sent[j] = b;
        if (b != -1 && thpref[j][sent[j]] > thpref[j][b]) {
          sent[j] = b;
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << sent[i] << " ";
  }
  return 0;
}
