#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  for (int tt = 0; tt < t; tt++) {
    int n;
    cin >> n;
    vector<bool> l(n), r(n);
    for (int i = 0; i < n; i++) {
      int k;
      cin >> k;
      for (int j = 0; j < k; j++) {
        int v;
        cin >> v;
        if (!l[i] && !r[v - 1]) {
          l[i] = r[v - 1] = true;
        }
      }
    }
    int x = n, y = n;
    for (int i = 0; i < n; i++) {
      if (!l[i]) x = min(x, i);
      if (!r[i]) y = min(y, i);
    }
    if (x == n) {
      cout << "OPTIMAL\n";
    } else {
      cout << "IMPROVE\n" << x + 1 << " " << y + 1 << "\n";
    }
  }
  return 0;
}
