#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<bool> a(n, false);
  vector<bool> c(n, false);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    vector<int> b(k);
    for (int j = 0; j < k; j++) {
      cin >> b[j];
      b[j]--;
    }
    bool flag = false;
    for (int j = 0; j < k; j++) {
      if (!a[b[j]]) {
        a[b[j]] = true;
        flag = true;
        break;
      }
    }
    c[i] = flag;
  }
  int ans1 = -1, ans2 = -1;
  for (int i = 0; i < n; i++) {
    if (!c[i]) {
      ans1 = i + 1;
    }
    if (!a[i]) {
      ans2 = i + 1;
    }
  }
  if (ans1 == -1) {
    cout << "OPTIMAL\n";
  } else {
    cout << "IMPROVE\n";
    cout << ans1 << ' ' << ans2 << '\n';
  }
}
int main() {
  string file("rvq");
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    solve();
  }
}
