#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); i++) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int N, M; cin >> N >> M; vector> hobby_persons_numhob_id(M); vector person_hobbies(N); vector> person_hobbies_set(N); vector<__int128> person_hash(N); rep(i, 0, N) { int numhob; cin >> numhob; if (numhob == 0) continue; rep(j, 0, numhob) { int h; cin >> h; h--; person_hobbies[i].push_back(h); person_hobbies_set[i].insert(h); hobby_persons_numhob_id[h].push_back(make_pair(numhob, i)); } sort(all(person_hobbies[i])); __int128 hash = 0; rep(j, 0, numhob) { __int128 K = 1822633612291; __int128 M = 927'216'262'826'281; assert(M < 1e18); hash = ((hash * K) + person_hobbies[i][j]) % M; } person_hash[i] = hash; } unordered_set candidates; rep(i, 0, M) { if (sz(hobby_persons_numhob_id[i]) < 2) continue; sort(all(hobby_persons_numhob_id[i])); rep(j, 0, sz(hobby_persons_numhob_id[i])-1) { int a = hobby_persons_numhob_id[i][j].second; int b = hobby_persons_numhob_id[i][j+1].second; if (sz(person_hobbies[a]) == sz(person_hobbies[b]) && person_hash[a] != person_hash[b]) { cout << "YES\n" << a << " " << b << endl; return 0; } else { candidates.insert(a*N+b); } } } for(ll ab : candidates) { ll a = ab/N; ll b = ab%N; // check if a has anything b is missing // maybe quadratic?? for(ll x : person_hobbies[a]) { if (person_hobbies_set[b].count(x) == 0) { cout << "YES\n" << a+1 << " " << b+1 << endl; return 0; } } } cout << "NO" << endl; }