#include <bits/stdc++.h>
using namespace std;
int vis[100005];
int main() {
  int T;
  cin >> T;
  while (T--) {
    memset(vis, 0, sizeof(vis));
    int n, k, gz1 = 0, wz1, f = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> k;
      f = 0;
      int minn = 100005, idex;
      for (int j = 1; j <= k; j++) {
        scanf("%d", &idex);
        if (vis[idex] == 1)
          continue;
        else if (f == 0 && vis[idex] == 0) {
          f = 1;
          vis[idex] = 1;
        }
      }
      if (f == 0) {
        gz1 = i;
      }
    }
    int i;
    if (gz1 == 0) {
      printf("OPTIMAL\n");
    } else {
      for (i = 1; i <= n; i++) {
        if (vis[i] == 0) {
          wz1 = i;
          break;
        }
      }
      printf("IMPROVE\n");
      printf("%d %d\n", gz1, wz1);
    }
  }
  return 0;
}
