#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
bool isPrime(int n) {
  if (n == 1)
    return false;
  else if (n == 2 || n == 3)
    return true;
  else if (n % 2 == 0 || n % 3 == 0)
    return false;
  else {
    for (int i = 5; i <= ceil(sqrt(n)); i = i + 6)
      if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
  }
}
inline string IntToString(long long a) {
  char x[100];
  sprintf(x, "%lld", a);
  string s = x;
  return s;
}
inline long long StringToInt(string a) {
  char x[100];
  long long res;
  strcpy(x, a.c_str());
  sscanf(x, "%lld", &res);
  return res;
}
inline string GetString(void) {
  char x[1000005];
  scanf("%s", x);
  string s = x;
  return s;
}
inline string uppercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); ++(i))
    if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
inline string lowercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); ++(i))
    if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
inline void OPEN(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t-- > 0) {
    int n;
    cin >> n;
    vector<bool> v(n + 1, true);
    v[0] = false;
    int flag = 0, da = 1;
    for (int i = 0; i < n; i++) {
      int temp;
      cin >> temp;
      if (temp == 0) da = i + 1;
      vector<int> a(temp);
      for (int k = 0; k < temp; k++) cin >> a[k];
      for (int j = 0; j < temp; j++) {
        if (v[a[j]] == true) {
          v[a[j]] = false;
          break;
        } else if (v[a[j]] == false && j == temp - 1) {
          da = i + 1;
        }
      }
    }
    int pa = 0;
    for (int i = 1; i <= n; i++) {
      if (v[i] == true) {
        flag = 1;
        pa = i;
        break;
      }
    }
    if (flag == 0)
      cout << "OPTIMAL" << endl;
    else {
      cout << "IMPROVE" << endl;
      cout << da << " " << pa << endl;
    }
  }
  return 0;
}
