#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<bool> used(n + 1);
  int unpaired = -1;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    bool done = false;
    for (int j = 0; j < k; j++) {
      int kingdom;
      cin >> kingdom;
      if (!done && !used[kingdom]) {
        done = true;
        used[kingdom] = true;
      }
    }
    if (!done) unpaired = i;
  }
  if (unpaired == -1) {
    cout << "OPTIMAL\n";
    return;
  }
  int kingdom = 1;
  while (used[kingdom]) kingdom++;
  cout << "IMPROVE\n" << unpaired << " " << kingdom << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
