#include <bits/stdc++.h>
using namespace std;
const long long mx = 100005;
bool isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
      c == 'E' || c == 'I' || c == 'O' || c == 'U')
    return true;
  return false;
}
bool prime[1000000];
vector<long long> primes;
void sieve(long long n) {
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * 2; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    x = (x * x) % 1000000007;
    y /= 2;
  }
  return res;
}
long long ncr(long long n, long long r) {
  if (r == 0 || r == n) return 1;
  long long d = 1LL, q = 1LL;
  for (long long i = 0; i < r; ++i) {
    d *= (n - i);
    d %= 1000000007;
    q *= (i + 1);
  }
  q = power(q, 1000000007 - 2);
  return (q * d) % 1000000007;
}
bool isprime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool visit[1000] = {false};
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long princes[n + 1];
    long long princesses[n + 1];
    for (long long i = 1; i <= n; i++) {
      princes[i] = 0;
      princesses[i] = 0;
    }
    vector<long long> v[n + 1];
    for (long long i = 1; i <= n; i++) {
      long long k;
      cin >> k;
      for (long long j = 0; j < k; j++) {
        long long x;
        cin >> x;
        v[i].push_back(x);
      }
    }
    long long count = 0;
    for (long long i = 1; i <= n; i++) {
      for (long long j = 0; j < v[i].size(); j++) {
        if (princes[v[i][j]] == 0) {
          princes[v[i][j]] = 1;
          princesses[i] = 1;
          count++;
          break;
        }
      }
    }
    if (count == n)
      cout << "OPTIMAL" << '\n';
    else {
      long long p, q;
      for (long long i = 1; i <= n; i++)
        if (princesses[i] == 0) {
          p = i;
          break;
        }
      for (long long i = 1; i <= n; i++)
        if (princes[i] == 0) {
          q = i;
          break;
        }
      cout << "IMPROVE" << '\n';
      cout << p << " " << q << '\n';
    }
  }
}
