#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int>> v1(n);
    int k, x;
    bool vis[n];
    bool used[n];
    bool married[n];
    for (int i = 0; i < n; ++i) {
      used[i] = false;
      married[i] = false;
    }
    for (int i = 0; i < n; ++i) {
      cin >> k;
      while (k--) {
        cin >> x;
        v1[i].push_back(x - 1);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int u : v1[i]) {
        if (used[u] == false) {
          married[i] = true;
          used[u] = true;
          break;
        }
      }
    }
    vector<pair<int, int>> newly;
    int untaken = -1;
    int untook = -1;
    for (int i = 0; i < n; i++) {
      if (used[i] == false) {
        untaken = i;
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      if (married[i] == false) {
        untook = i;
        break;
      }
    }
    if (untaken != -1 && untook != -1)
      newly.push_back(make_pair(untook + 1, untaken + 1));
    if (newly.size() == 0)
      cout << "OPTIMAL" << endl;
    else {
      cout << "IMPROVE" << endl;
      cout << newly[0].first << " " << newly[0].second << endl;
    }
  }
}
