#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int it = 0; it < t; ++it) {
    int n;
    cin >> n;
    vector<bool> usedA(n, 0);
    vector<bool> usedB(n, 0);
    for (int i = 0; i < n; ++i) {
      int k;
      cin >> k;
      bool update = false;
      for (int j = 0; j < k; ++j) {
        int val;
        cin >> val;
        if (!usedB[--val] && !update) {
          usedA[i] = true;
          usedB[val] = true;
          update = true;
        }
      }
    }
    bool ans = false;
    for (int i = 0; i < n; ++i) {
      if (!usedA[i]) {
        for (int j = 0; j < n; ++j) {
          if (!usedB[j]) {
            ans = true;
            cout << "IMPROVE\n";
            cout << i + 1 << " " << j + 1 << "\n";
          }
          if (ans) break;
        }
      }
      if (ans) break;
    }
    if (!ans) {
      cout << "OPTIMAL\n";
    }
  }
  return 0;
}
