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