#include <bits/stdc++.h>
using namespace std;
int t, n, k, x, lastAvailable;
set<int> adj[100001];
set<int> invalid;
bool available[100001];
bool vis[100001];
void solve(int princess) {
  int i = 1;
  while (!available[i]) {
    i++;
  }
  cout << princess << " " << i << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    memset(available, true, sizeof available);
    memset(vis, false, sizeof vis);
    for (int i = 1; i <= n; ++i) {
      cin >> k;
      for (int j = 0; j < k; ++j) {
        cin >> x;
        adj[i].insert(x);
      }
    }
    for (int i = 1; i <= n; ++i) {
      if (!adj[i].empty()) {
        bool ok = true;
        set<int>::iterator itr = adj[i].begin();
        while (itr != adj[i].end()) {
          if (!available[*itr])
            itr++;
          else
            break;
        }
        if (itr == adj[i].end()) {
          invalid.insert(i);
        }
        if (itr != adj[i].end()) available[*itr] = false;
      } else {
        invalid.insert(i);
      }
    }
    if (!invalid.empty()) {
      cout << "IMPROVE\n";
      solve(*invalid.begin());
    } else
      cout << "OPTIMAL\n";
    for (int i = 1; i <= n; ++i) adj[i].clear();
    invalid.clear();
  }
  return 0;
}
