#include <bits/stdc++.h>
using namespace std;
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline long long mnz(long long& a, long long b) { return a = (a > b ? b : a); }
inline long long mxz(long long& a, long long b) { return a = (a < b ? b : a); }
inline string toString(long long n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
double const eps = 1e-6;
long long const Base = 1e9 + 7, oo = 1e17, MAXN = 1e6;
long long A[MAXN + 5];
vector<long long> dske[MAXN + 5];
bitset<MAXN + 5> bi;
long long Solves() {
  long long n, m, k, cnt = 0, ans = 0, x = -1, y = -1, q, c, sum = 0, v, t = -1;
  cin >> n;
  for (long long i = 1; i <= n; i++) dske[i].clear(), bi[i] = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> k;
    c = 0;
    while (k--) {
      cin >> x;
      if (!bi[x] and !c) c = x;
    }
    if (c)
      bi[c] = 1;
    else
      y = i;
  }
  if (y == -1) return cout << "OPTIMAL" << endl, 0;
  vector<long long> vec;
  for (long long i = 1; i <= n; i++)
    if (!bi[i]) vec.push_back(i);
  map<long long, long long> mm;
  for (long long i = 0; i < dske[y].size(); i++) mm[dske[y][i]] = 1;
  for (long long i = 0; i < vec.size(); i++) {
    if (!mm[vec[i]]) {
      cout << "IMPROVE" << endl;
      cout << y << " " << vec[i] << endl;
      return 0;
    }
  }
  assert(0);
  return 0;
}
int main() {
  if (fopen("locin.txt", "r")) freopen("locin.txt", "r", stdin);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  for (long long T = 1; T <= test; T++) {
    Solves();
  }
}
