#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, un = 0;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) v[i] = 0;
    for (long long i = 0; i < n; i++) {
      long long k;
      cin >> k;
      long long a = 1;
      for (long long j = 0; j < k; j++) {
        long long pr;
        cin >> pr;
        if (!v[pr - 1] && a) {
          v[pr - 1] = 1;
          a = 0;
        }
      }
      if (a == 1) un = i + 1;
    }
    if (un == 0)
      cout << "OPTIMAL" << endl;
    else {
      cout << "IMPROVE" << endl;
      cout << un << " ";
      for (long long i = 0; i < n; i++) {
        if (v[i] == 0) {
          cout << i + 1 << endl;
          break;
        }
      }
    }
  }
}
