#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int ik = 0; ik < t; ik++) {
    int n;
    cin >> n;
    vector<bool> v(n + 1, true);
    vector<int> v1;
    v[0] = false;
    int count = 0;
    for (int i = 0; i < n; i++) {
      int k;
      cin >> k;
      int count = 0;
      for (int j = 0; j < k; j++) {
        int a;
        cin >> a;
        if (v[a]) {
          v[a] = false;
          j++;
          while (j < k) {
            cin >> a;
            j++;
          }
        }
        if (j == k - 1) {
          v1.push_back(i + 1);
        }
      }
      if (k == 0) v1.push_back(i + 1);
    }
    count = 0;
    if (!v1.empty()) {
      auto it = find(v.begin(), v.end(), true);
      if (it != v.end()) {
        int ans = it - v.begin();
        cout << "IMPROVE" << endl << v1[0] << " " << ans << endl;
        count = 1;
      }
    }
    if (count == 0) cout << "OPTIMAL" << endl;
  }
}
