#include <bits/stdc++.h>
using namespace std;
long long n;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<vector<long long>> v(n);
    for (long long i = 0; i < n; i++) {
      long long k;
      cin >> k;
      for (long long j = 0; j < k; j++) {
        long long x;
        cin >> x;
        v[i].push_back(x);
      }
    }
    vector<long long> done(n + 1, 0), girl(n, 0);
    for (long long i = 0; i < n; i++) {
      for (auto x : v[i]) {
        if (!done[x]) {
          done[x] = 1;
          girl[i] = 1;
          break;
        }
      }
    }
    long long f1 = -1, f2 = -1;
    for (long long i = 0; i < n; i++) {
      if (!girl[i]) f1 = i + 1;
    }
    for (long long i = 1; i <= n; i++) {
      if (!done[i]) f2 = i;
    }
    if (f1 == -1 || f2 == -1)
      cout << "OPTIMAL\n";
    else {
      cout << "IMPROVE\n";
      cout << f1 << " " << f2 << "\n";
    }
  }
}
