#include <bits/stdc++.h>
using namespace std;
vector<int> gr[100002];
bool prince[100002], taken;
int main() {
  int t, n, k, val;
  scanf("%d", &t);
  while (t--) {
    memset(prince, false, sizeof(prince));
    scanf("%d", &n);
    int princess = 0;
    for (int i = 0; i < n; ++i) {
      taken = false;
      scanf("%d", &k);
      for (int j = 0; j < k; ++j) {
        scanf("%d", &val);
        if (!prince[val] && !taken) prince[val] = true, taken = true;
      }
      if (!taken) princess = i + 1;
    }
    if (princess == 0)
      printf("OPTIMAL\n");
    else {
      for (int i = 1; i <= n; i++)
        if (!prince[i]) {
          printf("IMPROVE\n%d %d\n", princess, i);
          break;
        }
    }
  }
}
