#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k, tp;
    cin >> n;
    vector<set<int>> lists;
    set<int> kings;
    set<int> dau;
    for (int i = 0; i < n; i++) {
      cin >> k;
      set<int> temp;
      for (int j = 0; j < k; j++) {
        cin >> tp;
        temp.insert(tp);
      }
      lists.push_back(temp);
      kings.insert(i + 1);
      dau.insert(i + 1);
    }
    for (int i = 0; i < n; i++) {
      for (auto it = lists[i].begin(); it != lists[i].end(); ++it) {
        if (kings.find(*it) != kings.end()) {
          kings.erase(*it);
          dau.erase(i + 1);
          break;
        }
      }
    }
    if (dau.size() > 0) {
      cout << "IMPROVE" << endl
           << *(dau.begin()) << " " << *(kings.begin()) << endl;
    } else {
      cout << "OPTIMAL" << endl;
    }
  }
  return 0;
}
