#include <bits/stdc++.h>
using namespace std;
const int max_size = 1e9 + 7;
vector<int> result;
int in = 0;
string mysubstr(string s, int i, int j) { return s.substr(i, j - i + 1); }
long long getBits(long long x) {
  int count = 0;
  while (x) {
    count += x & 1;
    x = x >> 1;
  }
  return count;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  int count = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int>> g(n, vector<int>());
    vector<int> visitedPrince(n, 0), visitedDau(n, 0);
    for (int i = 0; i < n; i++) {
      int c;
      cin >> c;
      for (int j = 0; j < c; j++) {
        int x;
        cin >> x;
        g[i].push_back(x - 1);
        if (visitedDau[i] == 0 && visitedPrince[g[i][j]] == 0) {
          visitedPrince[g[i][j]] = 1;
          visitedDau[i] = 1;
        }
      }
    }
    bool pairFound = false;
    int resp = 0, resd = 0;
    for (int i = 0; i < n; i++) {
      if (visitedDau[i] == 1) continue;
      for (int j = 0; j < n; j++) {
        if (visitedPrince[j] == 0 && visitedDau[i] == 0) {
          resp = j + 1;
          resd = i + 1;
          pairFound = true;
          break;
        }
      }
      if (pairFound) {
        break;
      }
    }
    if (pairFound) {
      cout << "IMPROVE" << endl;
      cout << resd << " " << resp << endl;
    } else {
      cout << "OPTIMAL" << endl;
    }
  }
  return 0;
}
