#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    int n;
    cin >> n;
    vector<vector<int>> a;
    int b[n + 1];
    for (int i = 0; i <= n; i++) b[i] = 0;
    int count = 0;
    int s = 0;
    for (int i = 0; i < n; i++) {
      vector<int> x;
      int k;
      cin >> k;
      int c = 0;
      for (int j = 0; j < k; j++) {
        int q;
        cin >> q;
        x.push_back(q);
        if (c == 0) {
          if (b[q] == 0) {
            b[q]++;
            count++;
            c = 1;
          }
        }
      }
      if (c == 0) s = i;
      a.push_back(x);
    }
    if (count == n) {
      cout << "OPTIMAL" << endl;
    } else {
      s++;
      int f = 0;
      for (int i = 0; i < n; i++) {
        if (b[i + 1] == 0) {
          f = i;
        }
      }
      f++;
      cout << "IMPROVE" << endl;
      cout << s << " " << f << endl;
    }
  }
  return 0;
}
