#include <bits/stdc++.h>   using namespace std;   int main() {     int fr[301][301];     int al[301];     int i, j, n;     cin >> n;     for (i = 1; i <= n; ++i)       for (j = 1; j <= n; ++j) cin >> fr[i][j];     for (i = 1; i <= n; ++i) cin >> al[i];     int k, best[301], best_time[301], cur;     for (j = 1; j <= n; ++j) {       best[j] = 301;       best_time[j] = 301;       for (i = 1; i <= n; ++i) {         if (j == 1 && i == 1) continue;         for (k = 1; k <= n; ++k)           if (al[k] <= i && al[k] != j) {             cur = al[k];             break;           }         for (k = 1; k <= n; ++k) {           if (cur == fr[j][k]) {             if (k < best[j]) {               best[j] = k;               best_time[j] = i;             }             break;           }         }       }     }     for (i = 1; i <= n; ++i) cout << best_time[i] <<   t ;   }   