#include <bits/stdc++.h>
using namespace std;
void cinar(long long* ar, long long n) {
  for (long long i = 0; i < n; i++) cin >> ar[i];
}
void out(long long* a, long long n) {
  for (long long i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long powexp(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long powexp(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long modInverse(long long a, long long p) { return powexp(a, p - 2, p); }
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long phi(long long n) {
  long long r = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      r -= r / i;
    }
  }
  if (n > 1) r -= r / n;
  return r;
}
void solve() {
  long long t;
  cin >> t;
  while (t--) {
    map<long long, long long> ma;
    long long n;
    cin >> n;
    bool vis[n];
    for (long long i = 0; i < n + 1; i++) vis[i] = false;
    vector<long long> v;
    for (long long i = 0; i < n; i++) {
      long long k;
      cin >> k;
      long long ar[k];
      for (long long i = 0; i < k; i++) {
        cin >> ar[i];
      }
      long long fl = 0;
      for (long long i = 0; i < k; i++) {
        if (vis[ar[i]] == false) {
          vis[ar[i]] = true;
          fl = 1;
          break;
        }
      }
      if (fl == 0) v.push_back(i);
    }
    if (v.size() != 0) {
      cout << "IMPROVE" << endl;
      cout << v[0] + 1 << " ";
      for (long long i = 1; i < n + 1; i++) {
        if (vis[i] == false) {
          cout << i << endl;
          break;
        }
      }
    } else
      cout << "OPTIMAL" << endl;
  }
}
int main() {
  fast();
  solve();
}
