#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, i, j, k, ind, t, x, kg, g, ans1, ans2;
  cin >> t;
  while (t--) {
    cin >> n;
    int queen[n + 1];
    int king[n + 1];
    memset(queen, 0, sizeof(queen));
    memset(king, 0, sizeof(king));
    vector<vector<int>> v;
    for (i = 1; i <= n; i++) {
      cin >> k;
      vector<int> vec;
      while (k--) {
        cin >> g;
        vec.push_back(g);
      }
      for (auto it : vec) {
        if (king[it] == 0) {
          king[it] = i;
          queen[i] = it;
          break;
        }
      }
      v.push_back(vec);
    }
    vector<int> v2;
    for (i = 1; i <= n; i++) {
      if (king[i] == 0) {
        v2.push_back(i);
      }
    }
    kg = 0;
    for (i = 1; i <= n; i++) {
      if (queen[i] == 0) {
        for (auto it : v2) {
          auto itr = find(v[i - 1].begin(), v[i - 1].end(), it);
          if (itr == v[i - 1].end()) {
            kg = 1;
            ans1 = i;
            ans2 = it;
            break;
          }
        }
      }
      if (kg == 1) break;
    }
    if (kg == 1) {
      cout << "IMPROVE" << endl;
      cout << ans1 << " " << ans2 << endl;
    } else
      cout << "OPTIMAL" << endl;
  }
  return 0;
}
