#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, d = 0, f, c = 0;
    cin >> n;
    long long int k, x;
    map<long long int, long long int> m;
    for (int i = 0; i < n; i++) {
      cin >> k;
      f = 0;
      for (int i = 0; i < k; i++) {
        cin >> x;
        if (f == 0 && m[x] == 0) {
          m[x] = 1;
          f = 1;
          c++;
        }
      }
      if (d == 0 && f == 0) {
        d = i + 1;
      }
    }
    if (c == n) {
      cout << "OPTIMAL" << endl;
    } else {
      cout << "IMPROVE" << endl;
      for (int i = 0; i < n; i++) {
        if (m[i + 1] == 0) {
          cout << d << " " << i + 1 << endl;
          break;
        }
      }
    }
  }
  return 0;
}
