#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int vis[N] = {0};
int dau[N];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(vis, 0, sizeof(vis));
    int n;
    scanf("%d", &n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int p;
      scanf("%d", &p);
      int minn = N;
      for (int j = 0; j < p; j++) {
        int a;
        scanf("%d", &a);
        if (vis[a] == 0) minn = min(minn, a);
      }
      if (minn == N)
        dau[cnt++] = i + 1;
      else
        vis[minn] = 1;
    }
    if (cnt == 0) {
      printf("OPTIMAL\n");
      continue;
    } else {
      printf("IMPROVE\n");
      for (int i = n; i >= 1; i--) {
        if (vis[i] == 0) {
          printf("%d %d\n", dau[--cnt], i);
          break;
        }
      }
    }
  }
  return 0;
}
