#include <bits/stdc++.h>
using namespace std;
vector<int> v[1000005];
int ok[2][1000005];
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) ok[0][i] = 0;
    set<int> s;
    for (int i = 0; i < n; i++) s.insert(i);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      v[i].clear();
      for (int j = 0; j < x; j++) {
        int a;
        cin >> a;
        v[i].push_back(a - 1);
      }
      for (int j = 0; j < v[i].size(); j++) {
        if (s.count(v[i][j])) {
          ok[0][i] = ok[1][v[i][j]] = 1;
          s.erase(v[i][j]);
          cnt++;
          break;
        }
      }
    }
    if (cnt == n)
      cout << "OPTIMAL" << endl;
    else {
      cout << "IMPROVE" << endl;
      for (int i = n - 1; i >= 0; i--) {
        if (ok[0][i] == 0) {
          cout << (i + 1) << " " << (*s.rbegin() + 1) << endl;
          ;
          break;
        }
      }
    }
  }
  return 0;
}
