#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
void calcul() {
  int n, printesa = -1;
  cin >> n;
  bitset<N> a(0), b(0);
  for (int i = 1; i <= n; i++) {
    int nr;
    cin >> nr;
    for (int j = 0; j < nr; j++) {
      int p;
      cin >> p;
      if (!a[i] && !b[p]) {
        b[p] = 1;
        a[i] = 1;
      }
    }
    if (!a[i]) {
      printesa = i;
    }
  }
  if (printesa == -1) {
    cout << "OPTIMAL\n";
    return;
  }
  cout << "IMPROVE\n" << printesa << " ";
  for (int i = 1; i <= n; i++) {
    if (!b[i]) {
      cout << i << "\n";
      return;
    }
  }
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    calcul();
  }
  return 0;
}
