#include <bits/stdc++.h>
using namespace std;
void marry(int j, vector<int> princes, vector<bool> &vis) {
  for (int i = 0; i < princes.size(); i++) {
    if (!vis[princes[i]]) {
      vis[princes[i]] = true;
      break;
    }
  }
  return;
}
int main() {
  vector<bool> vis;
  int n, k, t;
  cin >> t;
  while (t--) {
    vector<vector<int>> all;
    bool ans = false;
    int x = -1, y = -1;
    cin >> n;
    vis.assign(n, false);
    for (int j = 0; j < n; j++) {
      cin >> k;
      vector<int> princes;
      for (int i = 0; i < k; i++) {
        int s;
        cin >> s;
        if (!vis[s - 1]) princes.push_back(s - 1);
      }
      if (princes.size() == 0) {
        x = j + 1;
      }
      marry(j, princes, vis);
    }
    if (x != -1) {
      for (int j = 0; j < n; j++) {
        if (!vis[j]) {
          y = j + 1;
          break;
        }
      }
    }
    if (x != -1 && y != -1) {
      cout << "IMPROVE\n" << x << " " << y << "\n";
    } else
      cout << "OPTIMAL\n";
  }
  return 0;
}
