#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return a > b; }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int in;
    vector<bool> p(n, 0), vis(n, 0);
    for (int i = 0; i < n; i++) {
      int k;
      cin >> k;
      for (int j = 0; j < k; j++) {
        cin >> in;
        in--;
        if (p[in] || vis[i])
          continue;
        else {
          p[in] = 1;
          vis[i] = 1;
        }
      }
    }
    bool band = false;
    int in1, in2;
    in1 = in2 = -1;
    for (int i = 0; i < n; i++) {
      if (!vis[i]) {
        in1 = i;
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      if (!p[i]) {
        in2 = i;
        break;
      }
    }
    if (in1 != -1) {
      cout << "IMPROVE\n";
      cout << in1 + 1 << " " << in2 + 1 << "\n";
    } else
      cout << "OPTIMAL\n";
  }
  return 0;
}
