#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    vector<int> v[n];
    int k, a;
    for (int i = 0; i < n; i++) {
      cin >> k;
      for (int j = 0; j < k; j++) {
        cin >> a;
        v[i].push_back(a);
      }
    }
    map<int, int> m;
    int mm;
    int p, ans = 0;
    for (int i = 0; i < n; i++) {
      for (p = 0; p < v[i].size(); p++) {
        if (m[v[i][p]] == 0) {
          m[v[i][p]] = 1;
          break;
        }
      }
      if (p == v[i].size()) ans = i + 1;
    }
    if (ans == 0)
      cout << "OPTIMAL"
           << "\n";
    else {
      cout << "IMPROVE"
           << "\n";
      cout << ans << " ";
      for (int l = 1; l <= n; l++) {
        if (m[l] == 0) {
          cout << l << "\n";
          break;
        }
      }
    }
  }
  return 0;
}
