#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    set<long long int> v;
    vector<long long int> v1;
    for (long long int i = 0; i < n; i++) {
      long long int k;
      cin >> k;
      long long int flag = 0;
      for (long long int j = 0; j < k; j++) {
        long long int elt;
        cin >> elt;
        if (v.count(elt) == 0 && !flag) {
          v.insert(elt);
          flag = 1;
        }
      }
      if (flag == 0) {
        v1.push_back(i + 1);
      }
    }
    if (v.size() == n) {
      cout << "OPTIMAL" << endl;
    } else {
      cout << "IMPROVE" << endl;
      if (v1.size() == n) {
        cout << "1 "
             << "1" << endl;
      } else {
        long long int index = 0;
        for (long long int i = 1; i <= n; i++) {
          if (v.count(i) == 0) {
            cout << v1[index] << " " << i;
            break;
          }
        }
        cout << endl;
      }
    }
  }
}
