#include <bits/stdc++.h>
using namespace std;
const int maxn = 310;
int nn[maxn][maxn];
int pri[maxn];
int mmax[maxn][2];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      mmax[i][0] = mmax[i][1] = 301;
      for (int j = 1; j <= n; j++) {
        cin >> nn[i][j];
      }
    }
    for (int i = 1; i <= n; i++) {
      int a;
      cin >> a;
      pri[a] = i;
    }
    pri[301] = 301;
    mmax[1][0] = 1;
    for (int i = 2; i <= n; i++) {
      if (pri[i] < pri[mmax[i - 1][0]]) {
        mmax[i][1] = mmax[i - 1][0];
        mmax[i][0] = i;
      } else if (pri[i] < pri[mmax[i - 1][1]]) {
        mmax[i][0] = mmax[i - 1][0];
        mmax[i][1] = i;
      } else {
        mmax[i][0] = mmax[i - 1][0];
        mmax[i][1] = mmax[i - 1][1];
      }
    }
    for (int i = 1; i <= n; i++) {
      int ans;
      for (int j = 1; j <= n; j++) {
        int time = nn[i][j];
        if (mmax[time][0] == i) {
          if (mmax[time][1] == nn[i][j]) {
            ans = time;
            break;
          } else
            continue;
        } else {
          if (mmax[time][0] == nn[i][j]) {
            ans = time;
            break;
          } else
            continue;
        }
      }
      cout << ans;
      if (i == n)
        cout << endl;
      else
        cout << ' ';
    }
  }
  return 0;
}
