#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    set<long long> d[n + 1];
    vector<long long> kingdom(n + 1, 0);
    for (long long i = 1; i < n + 1; i++) {
      long long k, x;
      cin >> k;
      for (long long j = 1; j < k + 1; j++) {
        cin >> x;
        d[i].insert(x);
      }
    }
    vector<long long> none;
    for (long long i = 1; i < n + 1; i++) {
      long long flag = 0;
      for (auto x : d[i]) {
        if (kingdom[x] != 1) {
          kingdom[x] = 1;
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        none.push_back(i);
      }
    }
    long long index2 = -1;
    long long index = -1;
    for (long long i = 1; i < n + 1; i++) {
      for (long long j = 0; j < none.size(); j++) {
        if (kingdom[i] == 0 && d[none[j]].find(i) == d[none[j]].end()) {
          index2 = i;
          index = none[j];
          break;
        }
      }
      if (index2 != -1) {
        break;
      }
    }
    if (none.size() == 0 || index2 == -1) {
      cout << "OPTIMAL \n";
    } else {
      cout << "IMPROVE \n";
      cout << index << " " << index2 << "\n";
    }
  }
}
