#include <bits/stdc++.h>
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
bool vis[maxn];
int find(int n) {
  int ans = -1;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) return ans = i;
  }
  return ans;
}
void init(int n) {
  for (int i = 1; i <= n; i++) vis[i] = 0;
}
int main(void) {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, end = -1;
    scanf("%d", &n);
    init(n);
    for (int i = 1; i <= n; i++) {
      int m, next = 0;
      scanf("%d", &m);
      if (m == 0) {
        end = i;
        continue;
      }
      for (int j = 1; j <= m; j++) {
        int t;
        scanf("%d", &t);
        if (next == 1) continue;
        if (next == 0 && vis[t] == 0) {
          vis[t] = next = 1;
          continue;
        }
        if (next == 0 && vis[t] == 1 && j == m) {
          end = i;
          continue;
        }
      }
    }
    if (end != -1)
      printf("IMPROVE\n%d %d\n", end, find(n));
    else
      puts("OPTIMAL");
  }
  return 0;
}
