#include <bits/stdc++.h>
void solve() {
  int n;
  scanf("%d", &n);
  std::vector<std::vector<int>> a(n);
  for (int i = 0, m; i < n; i++) {
    scanf("%d", &m);
    for (int j = 0, x; j < m; j++) {
      scanf("%d", &x);
      a[i].push_back(x - 1);
    }
  }
  std::vector<int> l(n), r(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (auto& x : a[i]) {
      if (!r[x]) {
        r[x] = true;
        l[i] = true;
        cnt++;
        break;
      }
    }
  }
  if (cnt == n) {
    puts("OPTIMAL");
  } else {
    int x = std::distance(l.begin(), std::find(l.begin(), l.end(), 0)) + 1;
    int y = std::distance(r.begin(), std::find(r.begin(), r.end(), 0)) + 1;
    printf("IMPROVE\n%d %d\n", x, y);
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
}
