#include <bits/stdc++.h>
using namespace std;
const int N = 32e4;
bool u[N];
int main() {
  ios::sync_with_stdio(0);
  int T, n, k;
  cin >> T;
  while (T--) {
    cin >> n;
    int v = 0, c = 0;
    for (int i = 1; i <= n; i++) {
      cin >> k;
      bool b = 0;
      for (int j = 0, x; j < k; j++) {
        cin >> x;
        if (!b && !u[x]) u[x] = b = 1;
      }
      if (!b && v == 0) v = i;
    }
    for (int j = 1; j <= n; j++)
      if (!u[j]) {
        c = j;
        break;
      }
    for (int i = 1; i <= n; i++) u[i] = 0;
    if (v)
      cout << "IMPROVE\n" << v << ' ' << c << '\n';
    else
      cout << "OPTIMAL\n";
  }
  return 0;
}
