#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T>
void printv(const vector<T>& s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int t;
  cin >> t;
  while (t) {
    t--;
    int n;
    cin >> n;
    vector<bool> sel(n, false);
    int l = -1, r = -1;
    for (int i = 0; i < n; ++i) {
      int m;
      cin >> m;
      int now = -1;
      for (int j = 0; j < m; ++j) {
        int to;
        cin >> to;
        to--;
        if (now == -1 && !sel[to]) {
          sel[to] = true;
          now = to;
        }
      }
      if (now == -1) l = i + 1;
    }
    for (int i = 0; i < n; ++i) {
      if (!sel[i]) {
        r = i + 1;
        break;
      }
    }
    if (l == -1 || r == -1) {
      cout << "OPTIMAL" << endl;
    } else {
      cout << "IMPROVE" << endl;
      cout << l << " " << r << endl;
    }
  }
}
