#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (long long i = 0; i < (t); i++) {
    int n;
    cin >> n;
    vector<bool> daughter(n, true);
    vector<bool> prince(n, true);
    int lastd = -1;
    for (long long j = 0; j < (n); j++) {
      int count;
      cin >> count;
      bool tmp = false;
      for (long long k = 0; k < (count); k++) {
        int p;
        cin >> p;
        if (daughter.at(j) && prince.at(p - 1)) {
          prince.at(p - 1) = false;
          tmp = true;
        }
        if (tmp) {
          daughter.at(j) = false;
        }
      }
      if (daughter.at(j)) {
        lastd = j;
      }
    }
    if (lastd == -1) {
      cout << "OPTIMAL" << endl;
    } else {
      for (int j = n - 1; j >= 0; j--) {
        if (prince.at(j)) {
          cout << "IMPROVE" << endl;
          cout << lastd + 1 << " " << j + 1 << endl;
          break;
        }
      }
    }
  }
  return 0;
}
