#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
using namespace std;
int n;
int vis1[maxn], vis2[maxn];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    memset(vis2, 0, sizeof(vis2));
    scanf("%d", &n);
    pair<int, int> ans;
    int tot = 0;
    for (int i = 1; i <= n; i++) {
      int k, flag = 0;
      scanf("%d", &k);
      while (k--) {
        int x;
        scanf("%d", &x);
        if (!flag && !vis2[x]) {
          flag = 1;
          vis2[x] = 1;
          tot++;
        }
      }
      if (!flag) ans.first = i;
    }
    if (tot == n)
      printf("OPTIMAL\n");
    else {
      printf("IMPROVE\n");
      for (int i = 1; i <= n; i++) {
        if (!vis2[i]) {
          printf("%d %d\n", ans.first, i);
          break;
        }
      }
    }
  }
  return 0;
}
