#include <bits/stdc++.h>
using namespace std;
int hx[] = {-2, -2, -1, -1, 1, 1, 2, 2};
int hy[] = {-1, 1, -2, 2, -2, 2, -1, 1};
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int nx[] = {1, -1, 0, 0, -1, 1, 1, -1};
int ny[] = {0, 0, 1, -1, 1, -1, 1, -1};
class pt {
 public:
  int x, y;
};
int main() {
  int t = 1;
  while (t--) {
    int n = ({
      int x;
      scanf("%d", &x);
      x;
    }),
        tmp;
    vector<vector<int> > ar(n + 1, vector<int>(n));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        tmp = ({
          int x;
          scanf("%d", &x);
          x;
        });
        ar[i + 1][tmp - 1] = j;
      }
    for (int i = 0; i < n; i++) {
      tmp = ({
        int x;
        scanf("%d", &x);
        x;
      });
      ar[0][tmp - 1] = i;
    }
    for (int i = 0; i < n; i++) {
      int pref = ((int)1e9), res = ((int)1e9), num = 0;
      for (int j = 0; j < n; j++) {
        if (i != j) {
          pref = min(pref, ar[0][j]);
          if (pref == ar[0][j] && res > ar[i + 1][j]) {
            res = ar[i + 1][j];
            num = j + 1;
          }
        }
      }
      cout << num << " ";
    }
    cout << endl;
  }
  return 0;
}
