#include <bits/stdc++.h>
using namespace std;
bool f[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, n, k;
  cin >> t;
  while (t--) {
    long long p = 0;
    cin >> n;
    for (long long i = 1; i <= n; ++i) {
      f[i] = 0;
    }
    for (long long i = 1; i <= n; ++i) {
      cin >> k;
      bool gas = 0;
      while (k--) {
        long long x = 0;
        cin >> x;
        if (!f[x] && !gas) {
          f[x] = 1;
          gas = 1;
        }
      }
      if (!gas) {
        p = i;
      }
    }
    if (p) {
      long long gas = 0;
      for (long long i = 1; i <= n && !gas; ++i) {
        if (!f[i]) {
          gas = i;
        }
      }
      if (gas) {
        cout << "IMPROVE\n" << p << " " << gas << "\n";
        continue;
      }
    }
    cout << "OPTIMAL\n";
  }
  return 0;
}
