#include <bits/stdc++.h>
using namespace std;
const int MxN = 1e5 + 2;
template <typename T>
void Write(T x) {
  if (x > 9) Write(x / 10);
  putchar(x % 10 + 48);
}
bool visit[MxN];
int q, _;
map<string, bool> mp;
bitset<MxN> bt;
void solve() {
  long long n, index, value;
  bool flag = 0;
  cin >> n;
  bitset<MxN> bt;
  bt[0] = 1;
  for (int i = 0; i < n; ++i) {
    long long nt, x;
    bool st = 0;
    cin >> nt;
    for (int j = 0; j < nt; ++j) {
      if (i == 0) {
        if (st == 0) {
          cin >> x;
          st = 1;
          bt[x] = 1;
        } else
          cin >> x;
      }
      if (i > 0) {
        if (st == 0) {
          cin >> x;
          if (bt[x] == 0) bt[x] = 1, st = 1;
        } else
          cin >> x;
      }
    }
    if (st == 0 && flag == 0) flag = 1, index = i + 1;
  }
  if (flag == 1) {
    for (int j = 1; j <= n; ++j)
      if (bt[j] == 0) {
        value = j;
        break;
      }
  }
  if (flag == 0)
    printf("OPTIMAL\n");
  else
    printf("IMPROVE\n%lld %lld\n", index, value);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> q;
  while (q--) {
    solve();
  }
}
