#include <bits/stdc++.h>
using namespace std;
int a[400][400];
int ans[400];
bool vis[400];
int main() {
  int n, i, j, k, z, fuck;
  bool ok;
  while (cin >> n) {
    memset(vis, 0, sizeof(vis));
    memset(ans, -1, sizeof(ans));
    for (i = 1; i <= n + 1; ++i)
      for (j = 1; j <= n; ++j) cin >> a[i][j];
    for (i = 1; i <= n; ++i) {
      vis[i] = 1;
      for (z = 1; z <= n; ++z)
        if (vis[a[n + 1][z]]) break;
      j = a[n + 1][z];
      fuck = -1;
      for (z++; z <= n; ++z)
        if (vis[a[n + 1][z]]) {
          fuck = a[n + 1][z];
          break;
        }
      for (k = 1; k <= n; ++k)
        if (k != j) {
          if (ans[k] == -1)
            ans[k] = j;
          else {
            for (z = 1; z <= n; ++z) {
              if (a[k][z] == j) {
                ans[k] = j;
                break;
              }
              if (a[k][z] == ans[k]) break;
            }
          }
        }
      if (fuck + 1) {
        if (ans[j] == -1)
          ans[j] = fuck;
        else {
          for (z = 1; z <= n; ++z) {
            if (a[j][z] == fuck) {
              ans[j] = fuck;
              break;
            }
            if (a[j][z] == ans[j]) break;
          }
        }
      }
    }
    cout << ans[1];
    for (i = 2; i <= n; ++i) cout << " " << ans[i];
    cout << endl;
  }
  return 0;
}
