#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    bool doug[100000] = {false}, princ[100000] = {false};
    for (int i{0}; i < n; i++) {
      int k;
      cin >> k;
      while (k--) {
        int pri;
        cin >> pri;
        if (!princ[pri - 1] && !doug[i]) {
          princ[pri - 1] = true;
          doug[i] = true;
        }
      }
    }
    bool done{false};
    for (int i{0}; i < n; i++) {
      if (!doug[i]) {
        for (int j{0}; j < n; j++) {
          if (!princ[j]) {
            cout << "IMPROVE" << endl;
            cout << i + 1 << " " << j + 1 << endl;
            done = true;
          }
          if (done) {
            break;
          }
        }
      }
      if (done) {
        break;
      }
    }
    if (!done) {
      cout << "OPTIMAL" << endl;
    }
  }
  return 0;
}
