#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  map<long long int, vector<long long int>> mp;
  vector<long long int> v;
  set<long long int> s;
  for (long long int i = 1; i <= n; i++) {
    long long int k;
    cin >> k;
    bool ok = 0;
    while (k--) {
      long long int x;
      cin >> x;
      mp[i].push_back(x);
      if (s.find(x) == s.end() and !ok) {
        ok = 1;
        s.insert(x);
      }
    }
    if (!ok) v.push_back(i);
  }
  for (long long int i : v) {
    for (long long int j = 1; i <= n; j++)
      if (s.find(j) == s.end() &&
          find(mp[i].begin(), mp[i].end(), j) == mp[i].end()) {
        cout << "IMPROVE\n" << i << " " << j << endl;
        return;
      }
  }
  cout << "OPTIMAL\n";
}
signed main() {
  ios::sync_with_stdio(false);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
