#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 15;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int n, k;
bool lef[maxn], rig[maxn];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) rig[i] = 1;
    for (int i = 1; i <= n; i++) {
      lef[i] = 1;
      int k, p;
      scanf("%d", &k);
      for (int j = 0; j < k; j++) {
        scanf("%d", &p);
        if (lef[i] == 0) continue;
        if (rig[p]) {
          rig[p] = 0;
          lef[i] = 0;
        }
      }
    }
    pair<int, int> ans = make_pair(-1, -1);
    for (int i = 1; i <= n; i++)
      if (rig[i]) ans.second = i;
    for (int i = 1; i <= n; i++)
      if (lef[i]) ans.first = i;
    if (ans.first != -1) {
      puts("IMPROVE");
      printf("%d %d\n", ans.first, ans.second);
    } else {
      puts("OPTIMAL");
    }
  }
  return 0;
}
