#include using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3") int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL)); int n, m; cin >> n >> m; vector> a(n); vector> cands(m + 1, {-1, -1}); vector hashval(m + 1); vector hash(n); for (int i = 0; i < m; ++i) { hashval[i] = (rand()<<16)^rand(); } for (int i = 0; i < n; ++i) { int k; cin >> k; a[i].resize(k); for (auto &x : a[i]) { cin >> x; --x; hash[i] ^= hashval[x]; } sort(a[i].begin(), a[i].end()); if(cands[k-1].first == -1) { cands[k-1].first = i; } else if (cands[k-1].second == -1 && hash[i] != hash[cands[k-1].first]) { cands[k-1].second = i; } } vector c; for (int bit = 0; bit < m; ++bit) { if (cands[bit].first != -1) { c.emplace_back(cands[bit].first); } if (cands[bit].second != -1) { c.emplace_back(cands[bit].second); } } auto test = [&](int i, int j) { int ptr1 = 0, ptr2 = 0; while (ptr1 < a[i].size() && ptr2 < a[j].size()) { if (a[i][ptr1] == a[i][ptr2]) { ++ptr1; ++ptr2; } if (a[j][ptr1] < a[j][ptr2]) { break; } else { ++ptr2; } } if (ptr1 < a[i].size()) { cout << "YES\n"; cout << c[i] + 1 << ' ' << c[j] + 1 << '\n'; exit(0); } }; for (int i = 0; i < c.size(); ++i) { for (int j = i+1; j < c.size(); ++j) { test(c[i], c[j]); } } cout << "NO\n"; return 0; }