#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint16_t N, M, i, j; cin >> N >> M; vector A(M); for (i = 0; i != M; ++i) cin >> A[i]; vector> T(N, vector(M)); for (i = 0; i != N; ++i) for (j = 0; j != M; ++j) cin >> T[i][j]; vector count(M, 0), ans(N, UINT16_MAX); for (i = 0; i != M; ++i) for (j = 0; j != N; ++j) if (ans[j] == UINT16_MAX && count[T[j][i]] != A[T[j][i]]) ++count[T[j][i]], ans[j] = T[j][i]; cout << ans[0]; for (i = 1; i != N; ++i) cout << ' ' << ans[i]; cout << '\n'; return 0; }