#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    set<int> s1, s2;
    for (int i = 0; i < n; i++) s2.insert(i);
    for (int i = 0; i < n; i++) {
      int k, flag = -1;
      cin >> k;
      while (k--) {
        int x;
        cin >> x;
        x--;
        if (flag == -1 && s2.count(x)) flag = x;
      }
      if (flag != -1)
        s2.erase(flag);
      else
        s1.insert(i);
    }
    if (s1.size() && s2.size()) {
      cout << "IMPROVE" << endl;
      cout << *s1.begin() + 1 << " " << *s2.begin() + 1 << endl;
    } else
      cout << "OPTIMAL" << endl;
  }
  return 0;
}
