#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    bool impr = false;
    bool taken[n + 1];
    for (int i = 0; i <= n; i++) {
      taken[i] = false;
    }
    int notTaken = -1;
    for (int i = 0; i < n; i++) {
      int k;
      cin >> k;
      bool done = false;
      for (int i = 0; i < k; i++) {
        int next;
        cin >> next;
        if (!done && !taken[next]) {
          taken[next] = true;
          done = true;
        }
      }
      if (!done) {
        impr = true;
        notTaken = i + 1;
      }
    }
    if (impr) {
      cout << "IMPROVE" << endl;
      int good = 0;
      for (int i = 1; i <= n; i++) {
        if (taken[i] == false) {
          good = i;
        }
      }
      cout << notTaken << " " << good << endl;
    } else {
      cout << "OPTIMAL" << endl;
    }
  }
}
