#include <bits/stdc++.h>
using namespace std;
int n;
const int MX = 1e5;
bool done[MX + 2];
void solve() {
  cin >> n;
  for (int i = 0, to = n; i < to; i++) done[i] = false;
  int id = -1;
  for (int i = 0, to = n; i < to; i++) {
    int k;
    cin >> k;
    int num;
    bool ok = false;
    for (int j = 0, to = k; j < to; j++) {
      cin >> num;
      num--;
      if (!done[num] && !ok) {
        ok = true;
        done[num] = true;
      }
    }
    if (!ok) id = i;
  }
  if (id != -1) {
    cout << "IMPROVE\n";
    for (int i = 0, to = n; i < to; i++)
      if (!done[i]) {
        cout << id + 1 << " " << i + 1 << '\n';
        break;
      }
  } else {
    cout << "OPTIMAL\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
