#include <bits/stdc++.h>
using namespace std;
const int inf = 1e09 + 31;
void solve() {
  int n, temp, temp2;
  cin >> n;
  vector<int> taken(n + 2), wanted(n + 2);
  for (int i = 0; i < n; i++) {
    cin >> temp;
    bool f = false;
    for (int j = 0; j < temp; j++) {
      cin >> temp2;
      temp2--;
      if (f) continue;
      if (taken[temp2]) {
      } else {
        taken[temp2] = 1;
        f = 1;
      }
    }
    wanted[i] = f;
  }
  for (int i = 0; i < n; i++) {
    if (wanted[i] == 0) {
      for (int j = 0; j < n; j++) {
        if (taken[j] == 0) {
          cout << "IMPROVE" << '\n' << i + 1 << " " << j + 1 << '\n';
          return;
        }
      }
    }
  }
  cout << "OPTIMAL" << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
