#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
using namespace std;
double EPS = 1e-7;
int a[300][300];
int b[300];
int B[300];
vector<int> c;
vector<int> res;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x--;
    b[x] = n - i;
  }
  for (int i = 0; i < n; i++) {
    c.clear();
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (c.empty())
        c.push_back(j);
      else {
        if (b[j] > b[c[c.size() - 1]]) c.push_back(j);
      }
    }
    for (int j = 0; j < n; j++) {
      B[a[i][j]] = n - j;
    }
    int mm = -1000000000, p = -1;
    for (int j = 0; j < c.size(); j++) {
      if (B[c[j]] > mm) {
        mm = B[c[j]];
        p = c[j];
      }
    }
    res.push_back(p + 1);
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] << ' ';
  }
}
