#include <bits/stdc++.h>
using namespace std;
typedef struct pinfo {
  int k;
  vector<int> princ;
} _pinfo;
int main() {
  int t;
  cin >> t;
  int n;
  int k;
  int x;
  while (t--) {
    cin >> n;
    vector<_pinfo> p(n);
    for (int i = 0; i < n; i++) {
      cin >> p[i].k;
      for (int j = 0; j < p[i].k; j++) {
        cin >> x;
        p[i].princ.push_back(x);
      }
    }
    vector<bool> prince(n, false);
    vector<bool> princess(n, false);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < p[i].k; j++) {
        if (!prince[p[i].princ[j] - 1]) {
          prince[p[i].princ[j] - 1] = true;
          princess[i] = true;
          break;
        }
      }
    }
    vector<int> unmarry;
    vector<int> princeunmarry;
    for (int i = 0; i < n; i++) {
      if (!prince[i]) {
        princeunmarry.push_back(i);
      }
    }
    for (int i = 0; i < n; i++) {
      if (!princess[i]) {
        unmarry.push_back(i);
      }
    }
    if (unmarry.size() == 0) {
      cout << "OPTIMAL" << '\n';
      continue;
    } else {
      cout << "IMPROVE" << '\n';
      int i = 0;
      while (i < 1) {
        cout << unmarry[i] + 1 << " " << princeunmarry[i] + 1 << '\n';
        i++;
      }
    }
  }
}
