#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, i, k, j;
    cin >> n;
    vector<vector<int> > D(n);
    for (i = 0; i < n; i++) {
      cin >> k;
      for (j = 0; j < k; j++) {
        int a;
        cin >> a;
        D[i].push_back(a);
      }
    }
    map<int, bool> mp1, mp2;
    for (i = 0; i < n; i++) {
      mp1[i] = false;
      mp2[i + 1] = false;
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < D[i].size(); j++) {
        if (mp2[D[i][j]] == false) {
          mp2[D[i][j]] = true;
          mp1[i] = true;
          break;
        }
      }
    }
    bool flag = false;
    for (i = 0; i < n; i++) {
      if (mp1[i] == false) {
        for (j = 1; j < n + 1; j++) {
          if (mp2[j] == false) {
            cout << "IMPROVE" << endl;
            cout << i + 1 << " " << j << endl;
            flag = true;
            break;
          }
        }
      }
      if (flag) {
        break;
      }
    }
    if (!flag) {
      cout << "OPTIMAL" << endl;
    }
  }
  return 0;
}
