#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int n1 = n;
    int k1;
    int k[n + 1];
    int pri[n + 1];
    for (int i = 1; i <= n; i++) {
      k[i] = 0;
      pri[i] = 0;
    }
    int f = 0;
    std::vector<int> nhi;
    for (int j = 1; j <= n; j++) {
      f = 0;
      cin >> k1;
      int pr[k1 + 1];
      for (int i = 1; i <= k1; i++) {
        cin >> pr[i];
      }
      for (int i = 1; i <= k1; i++) {
        if (k[pr[i]] == 0) {
          k[pr[i]] = 1;
          pri[j] = 1;
          break;
        }
      }
      if (pri[j] == 0) {
        nhi.push_back(j);
      }
    }
    if (nhi.empty())
      cout << "OPTIMAL"
           << "\n";
    else {
      int g;
      for (int i = 1; i <= n; i++) {
        if (k[i] == 0) {
          g = i;
          break;
        }
      }
      cout << "IMPROVE"
           << "\n";
      cout << nhi[0] << " " << g << "\n";
    }
  }
  return 0;
}
