#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, k;
    cin >> n;
    int boy[n], girl[n];
    memset(girl, -1, sizeof(girl));
    memset(boy, -1, sizeof(boy));
    for (int i = 0; i < n; i++) {
      cin >> m;
      int a[m];
      for (int j = 0; j < m; j++) {
        cin >> a[j];
        a[j]--;
      }
      for (int j = 0; j < m; j++) {
        if (boy[a[j]] == -1) {
          boy[a[j]] = i;
          girl[i] = a[j];
          break;
        }
      }
    }
    int unmGirl = -1, unmBoy;
    for (int i = 0; i < n; i++) {
      if (girl[i] == -1) {
        unmGirl = i;
      }
      if (boy[i] == -1) {
        unmBoy = i;
      }
    }
    if (unmGirl == -1) {
      cout << "OPTIMAL" << endl;
    } else {
      cout << "IMPROVE" << endl;
      cout << unmGirl + 1 << " " << unmBoy + 1 << endl;
    }
  }
}
