#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, n, n2, m, t, j, l, pos, mpos, f = 0, k, p, x, n1, x1, x2, y1, y2,
                                             r, y;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<vector<long long> > a;
    f = 0;
    std::vector<bool> c(n, false);
    std::vector<bool> d(n, false);
    set<long long> s;
    for (i = 0; i < n; i++) {
      cin >> m;
      vector<long long> b(m);
      for (j = 0; j < m; j++) {
        cin >> b[j];
      }
      for (j = 0; j < m; j++) {
        if (s.find(b[j]) == s.end()) {
          s.insert(b[j]);
          d[i] = true;
          c[b[j] - 1] = true;
          break;
        }
      }
      a.push_back(b);
    }
    for (i = 0; i < n; i++)
      if (!c[i]) {
        for (j = 0; j < n; j++) {
          if (!d[j]) {
            x = i + 1;
            if (!binary_search(a[j].begin(), a[j].end(), x)) {
              cout << "IMPROVE\n";
              cout << j + 1 << " " << i + 1 << endl;
              i = n;
              f = 1;
              break;
            }
          }
        }
      }
    if (!f) {
      cout << "OPTIMAL\n";
    }
  }
  return 0;
}
