#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int t, ans1, ans2;
  cin >> t;
  while (t--) {
    unsigned long long int n, num, m;
    vector<vector<unsigned long long int> > vec;
    cin >> n;
    int flag1 = 0;
    for (unsigned long long int i = 0; i < n; i++) {
      vector<unsigned long long int> v1;
      cin >> m;
      if (m == 0) {
        flag1 = 1;
        ans2 = i + 1;
      }
      for (unsigned long long int j = 0; j < m; j++) {
        cin >> num;
        v1.push_back(num);
      }
      vec.push_back(v1);
    }
    int flag = 0;
    set<int> s;
    for (unsigned long long int i = 0; i < vec.size(); i++) {
      for (unsigned long long int j = 0; j < vec[i].size(); j++) {
        if (s.find(vec[i][j]) == s.end()) {
          s.insert(vec[i][j]);
          break;
        } else if ((j == vec[i].size() - 1) && !flag) {
          ans1 = i + 1;
          flag = 1;
        }
      }
    }
    for (unsigned long long int i = 1; i <= n; i++) {
      if (s.find(i) == s.end() && !flag1) {
        cout << "IMPROVE" << '\n';
        cout << ans1 << " " << i << '\n';
        break;
      } else if (s.find(i) == s.end() && flag1) {
        cout << "IMPROVE" << '\n';
        cout << ans2 << " " << i << '\n';
        break;
      }
    }
    if (!flag && !flag1) {
      cout << "OPTIMAL" << '\n';
    }
  }
  return 0;
}
