#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[301][301];
  int n;
  cin >> n;
  for (int i = 0; i < 301; i++)
    for (int j = 0; j < 301; j++) a[i][j] = 0;
  int rez[301] = {0};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  int b[301] = {0};
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    temp--;
    b[temp] = i;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (a[i][j] == i)
        continue;
      else {
        bool flag = true;
        for (int k = 0; k < a[i][j] && flag; k++)
          if (b[k] < b[a[i][j]] && k != i) flag = false;
        if (flag) {
          rez[i] = a[i][j] + 1;
          break;
        } else
          continue;
      }
  }
  for (int i = 0; i < n; i++) cout << rez[i] << " ";
}
