#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
const long long inf = 1e18 + 5;
bool sortbysec(const pair<pair<long long, long long>, long long> &a,
               const pair<pair<long long, long long>, long long> &b) {
  return (a.second > b.second);
}
long long powermod(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool isprime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  long long cnt = 0;
loop:
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> vis(n, 0);
    vector<long long> rem;
    for (long long i = 0; i < n; i++) {
      long long size;
      cin >> size;
      long long g = 0;
      vector<long long> choice(size);
      for (long long j = 0; j < size; j++) {
        cin >> choice[j];
        if (g == 0 && !vis[choice[j] - 1]) {
          g = 1;
          vis[choice[j] - 1] = 1;
        }
      }
      if (g == 0) {
        rem.push_back(i);
      }
    }
    if (rem.size() == 0) {
      cout << "OPTIMAL"
           << "\n";
    }
    for (long long i = 0; i < rem.size(); i++) {
      for (long long j = 0; j < n; j++) {
        if (!vis[j]) {
          cout << "IMPROVE"
               << "\n";
          cout << rem[i] + 1 << " " << j + 1 << "\n";
          goto loop;
        }
      }
    }
  }
  return 0;
}
