#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T checkmin(T &a, T b) {
  return (a < b) ? a : a = b;
}
template <class T>
inline T checkmax(T &a, T b) {
  return (a > b) ? a : a = b;
}
template <class T>
T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (a == 0) ? b : GCD(b % a, a);
}
template <class T>
T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return (a == 0 || b == 0) ? 0 : a / GCD(a, b) * b;
}
template <class T>
inline T sqr(T X) {
  return X * X;
}
namespace Geometry {
inline int Sig(long double X) {
  if (fabs(X) < 1e-10) return 0;
  return (X < 0) ? -1 : 1;
}
inline long double Det(complex<double> A, complex<double> B) {
  return real(A) * imag(B) - real(B) * imag(A);
}
inline complex<double> CrossPoint(complex<double> A, complex<double> B,
                                  complex<double> C, complex<double> D) {
  double S1 = Det(B - A, C - A);
  double S2 = Det(D - A, B - A);
  return (C * S2 + D * S1) / (S1 + S2);
}
inline bool CompareXY(complex<double> A, complex<double> B) {
  return real(A) < real(B) || (real(A) == real(B) && imag(A) < imag(B));
}
}  // namespace Geometry
namespace Poor {
const int MaxiN = 305;
int N;
int Like[MaxiN][MaxiN];
bool Have[MaxiN];
int Time[MaxiN];
int Most(int k, int t) {
  for (int j = t; j <= N; ++j)
    if (Have[Like[k][j]]) return j;
  return 0;
}
void Update(int k, int i) {
  if (Time[k] == 0) {
    Time[k] = i;
    return;
  }
  for (int j = 1; j <= N; ++j) {
    if (Like[k][j] == Time[k]) return;
    if (Like[k][j] == i) {
      Time[k] = i;
      return;
    }
  }
}
void Run() {
  cin >> N;
  for (int i = 1; i <= N + 1; ++i)
    for (int j = 1; j <= N; ++j) cin >> Like[i][j];
  for (int i = 1; i <= N; ++i) {
    Have[i] = 1;
    int Best = Most(N + 1, 1);
    int Sec = Most(N + 1, Best + 1);
    Best = Like[N + 1][Best];
    if (Sec > 0) Sec = Like[N + 1][Sec];
    if (Sec == i) Update(Best, i);
    if (Best == i) {
      for (int j = 1; j <= N; ++j)
        if (i != j) Update(j, i);
    }
  }
  for (int i = 1; i <= N; ++i) printf("%d%c", Time[i], (i == N) ? '\n' : ' ');
}
}  // namespace Poor
int main() {
  Poor::Run();
  return 0;
}
