#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, count = 1, ans = 0, a, b, freq[N] = {0}, pf, v;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a;
      v = 0;
      for (int j = 0; j < a; j++) {
        cin >> b;
        if (j < count && !v) {
          if (!freq[b]) {
            v = 1;
            freq[b]++;
          }
        }
      }
      if (!v) {
        pf = i + 1;
      }
      count++;
    }
    v = 0;
    for (int i = 1; i <= n; i++) {
      if (!freq[i]) {
        v = i;
        break;
      }
    }
    if (v) {
      cout << "IMPROVE\n" << pf << " " << v << "\n";
    } else {
      cout << "OPTIMAL\n";
    }
  }
}
