#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, prindex, k, kingdom, ki, prince;
  cin >> t;
  for (int h = 0; h < t; h++) {
    cin >> n;
    vector<int> vec(n + 7, 0);
    prindex = 0, k, kingdom, ki, prince = 1;
    for (int i = 1; i <= n; i++) {
      cin >> k;
      ki = 0;
      for (int j = 0; j < k; j++) {
        cin >> kingdom;
        if (ki == 0 and vec[kingdom] == 0) {
          vec[kingdom]++;
          ki++;
        }
      }
      if (ki == 0) prindex = i;
    }
    for (int i = 1; i <= n and vec[i] != 0; i++) prince = i + 1;
    if (prindex > 0)
      cout << "IMPROVE"
           << "\n"
           << prindex << " " << prince << "\n";
    else
      cout << "OPTIMAL"
           << "\n";
  }
  return 0;
}
