#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()); a[i].emplace_back(1e9); 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; bool ok1 = false, ok2 = false, ok3 = false; while ((ptr1 < a[i].size()-1 || ptr2 < a[j].size()-1) && !(ok1 && ok2 && ok3)) { if (a[i][ptr1] == a[j][ptr2]) { ++ptr1; ++ptr2; ok1 = true; continue; } if (a[i][ptr1] < a[j][ptr2]) { ++ptr1; ok2 = true; } else { ++ptr2; ok3 = true; } } if (ok1 && ok2 && ok3) { cout << "YES\n"; cout << i + 1 << ' ' << 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; }