#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int z1 = 10000000;
    unordered_map<long long int, long long int> mp;
    long long int a[100005];
    long long int n, k, i, j;
    cin >> n;
    for (i = 1; i <= n; i++) {
      cin >> k;
      long long int x, c = 0;
      for (j = 0; j < k; j++) {
        cin >> a[j];
      }
      for (j = 0; j < k; j++) {
        if (mp[a[j]] == 0) {
          mp[a[j]] = 1;
          c = 1;
          break;
        }
      }
      if (c == 0 && z1 == 10000000) {
        z1 = i;
      }
    }
    if (z1 == 10000000) {
      cout << "OPTIMAL"
           << "\n";
    } else {
      cout << "IMPROVE"
           << "\n";
      cout << z1 << " ";
      for (long long int k1 = 1; k1 <= n; k1++) {
        if (mp[k1] == 0) {
          cout << k1 << "\n";
          break;
        }
      }
    }
  }
  return 0;
}
