#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> k(n + 1), p(n);
    int mi = -1, qt = 0;
    for (int i = (0); i < (n); i++) {
      int q;
      cin >> q;
      bool done = false;
      while (q--) {
        int x;
        cin >> x;
        if (done) continue;
        if (k[x] == 0) {
          k[x] = 1;
          p[i] = 1;
          qt++;
          done = true;
        }
      }
    }
    if (qt == n) {
      cout << "OPTIMAL"
           << "\n";
    } else {
      cout << "IMPROVE"
           << "\n";
      for (int i = 0; i < n; i++) {
        if (p[i] == 0) {
          cout << i + 1 << " ";
          for (int j = 1; j <= n; j++) {
            if (k[j] == 0) {
              cout << j << "\n";
              break;
            }
          }
          break;
        }
      }
    }
  }
}
