#include <bits/stdc++.h>
using namespace std;
int b[100000];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    b[i] = 0;
  }
  int k;
  int cur;
  bool ok;
  bool ans = false;
  int an, add;
  for (int i = 0; i < n; ++i) {
    cin >> k;
    ok = false;
    for (int j = 0; j < k; ++j) {
      cin >> cur;
      if (ok) {
        continue;
      }
      if (b[cur - 1] == 0) {
        ok = true;
        b[cur - 1] = 1;
      }
    }
    if (ok == false) {
      ans = true;
      an = i;
    }
  }
  if (ans) {
    for (int i = 0; i < n; ++i) {
      if (b[i] == 0) {
        add = i + 1;
        break;
      }
    }
    cout << "IMPROVE\n";
    cout << an + 1 << " " << add << "\n";
  } else {
    cout << "OPTIMAL\n";
  }
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
