#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  long long n;
  for (long long i = 1; i <= t; i++) {
    cin >> n;
    long long ara[n + 1];
    for (long long j = 1; j <= n; j++) ara[j] = 0;
    long long ind = 0;
    for (long long z = 1; z <= n; z++) {
      long long k;
      cin >> k;
      long long lis[k];
      for (long long j = 0; j < k; j++) cin >> lis[j];
      sort(lis, lis + k);
      long long flag = 0;
      for (long long j = 0; j < k; j++) {
        if (ara[lis[j]] == 0) {
          flag = 1;
          ara[lis[j]] = 1;
          break;
        }
      }
      if (flag == 0) ind = z;
    }
    if (ind == 0) {
      cout << "OPTIMAL" << endl;
    } else {
      long long f = 0;
      for (long long j = 1; j <= n; j++) {
        if (ara[j] == 0) {
          cout << "IMPROVE" << endl;
          cout << ind << " " << j << endl;
          f = 1;
          break;
        }
      }
      if (f == 0) cout << "OPTIMAL" << endl;
    }
  }
  return 0;
}
