#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; void solve1(vector>& P, int root) {} int main() { FAST_IO int N, K; cin >> N >> K; vector P(N - 1, vector(N, 0)); for (int i = 0; i < N - 1; i++) { for (int j = 0; j < N; j++) { cin >> P[i][j]; P[i][j]--; } } set S1, S2; S1.insert(0); S2.insert(N - 1); int to1 = 0; int to2 = N - 1; set g1, g2; for (int i = 0; i < K; i++) { g1.insert(i); } for (int i = K; i < N - 1; i++) { g2.insert(i); } vector Q(N, -1); while (K != 0 && K != N - 1) { bool flg = false; if (g1.size() > 0) { auto g = *g1.begin(); g1.erase(g); int to = to2; int from = P[g][to]; if (S1.contains(from)) flg = true; S2.insert(from); Q[to] = g; to2 = from; } else { auto g = *g2.begin(); g2.erase(g); int to = to1; int from = P[g][to]; if (from < 0) continue; if (S2.contains(from)) flg = true; S1.insert(from); Q[to] = g; to1 = from; } if (flg) break; } set S; if (K != 0) for (auto s : S1) S.insert(s); if (K != N - 1) for (auto s : S2) S.insert(s); set G; for (auto g : g1) G.insert(g); for (auto g : g2) G.insert(g); while (G.size() > 0) { int found = -1; for (int g : G) { for (int to = 0; to < N; to++) { int from = P[g][to]; if (from < 0) continue; if (S.contains(from) && !S.contains(to)) { S.insert(to); Q[to] = g; found = g; break; } } if (found >= 0) break; } G.erase(found); } cout << "Yes" << endl; for (auto e : Q) { cout << (e + 1) << " "; } cout << endl; }