#include <bits/stdc++.h>
using namespace std;
int a[305][305];
int p[305];
int ans[305][305];
struct node {
  int val, p;
  node() {}
  node(int x, int y) {
    val = x;
    p = y;
  }
};
bool operator<(node c, node d) { return c.p < d.p; }
set<node> s;
int main() {
  int n, x;
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> x;
      a[i][x] = j;
    }
  for (int i = 0; i < n; i++) {
    cin >> x;
    p[x] = i + 1;
  }
  set<node>::iterator it;
  for (int i = 1; i <= n; i++) {
    s.insert(node(i, p[i]));
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      it = s.begin();
      while (it->val == j) it++;
      ans[j][i] = a[j][it->val];
    }
  }
  int wow[305];
  int best;
  for (int i = 1; i <= n; i++) {
    best = n + 1;
    for (int j = 1; j <= n; j++) {
      if (i != j) {
        if (ans[i][j] < best) {
          wow[i] = j;
          best = ans[i][j];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << wow[i] << " ";
  return 0;
}
