#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
const int sz = 1e5 + 3, inf = 1e9 + 10;
int a[sz], match[sz], c[sz];
int fr[sz];
bool vis[sz];
long long int x[sz];
void solve() {
  memset(vis, 1, sizeof vis);
  memset(match, 0, sizeof match);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) cin >> a[j];
    for (int j = 0; j < k; j++) {
      if (vis[a[j]]) {
        vis[a[j]] = 0;
        match[i] = a[j];
        break;
      }
    }
  }
  bool f = 0;
  for (int i = 1; i <= n; i++) {
    if (match[i]) continue;
    for (int j = 1; j <= n; j++) {
      if (vis[j]) {
        cout << "IMPROVE\n";
        cout << i << " " << j << "\n";
        f = 1;
        break;
      }
    }
    if (f) break;
  }
  if (!f) cout << "OPTIMAL\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
