#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t > 0) {
    int n = 0, flag = 0;
    cin >> n;
    int prince[n], princess[n];
    for (int m = 0; m < n; m++) {
      prince[m] = 0;
    }
    for (int m = 0; m < n; m++) {
      princess[m] = 0;
    }
    for (int i = 0; i < n; i++) {
      int k, j, choice, found = 0;
      cin >> j;
      for (k = 1; k <= j; k++) {
        cin >> choice;
        if (!prince[choice - 1] && !found) {
          prince[choice - 1] = 1;
          princess[i] = 1;
          found = 1;
        }
      }
    }
    for (int d = 0; d < n && !flag; d++) {
      if (!princess[d]) {
        for (int e = 0; e < n; e++) {
          if (!prince[e]) {
            cout << "IMPROVE" << endl;
            cout << d + 1 << " " << e + 1 << endl;
            flag = 1;
            break;
          }
        }
      }
    }
    if (!flag) {
      cout << "OPTIMAL" << endl;
    }
    t--;
  }
}
