#include <bits/stdc++.h>
using namespace std;
bool is_prime(long long n) {
  if (n == 2) return true;
  if (n < 2) return false;
  for (long long i = 3; i * i <= n; ++i)
    if (!(n % i)) return false;
  return true;
}
vector<long long> divison(long long n) {
  vector<long long> v;
  for (long long i = 1; i * i <= n; ++i)
    if (!(n % i)) v.push_back(i), v.push_back(n / i);
  return v;
}
void printnumberinbinary(unsigned long long t) {
  if (!t) return;
  printnumberinbinary(t >> 1);
  cout << (t & 1);
}
int numberofdiv(int t) {
  int ans = 0, x;
  for (x = 1; x * x < t; x++) {
    if (!(t % x)) ans += 2;
  }
  if (x * x == t) ans++;
  return ans;
}
vector<set<int>> adj(1e5 + 1);
vector<bool> vis(1e5 + 1);
void dfs(int t) {
  cout << t << " ";
  vis[t] = true;
  for (auto f : adj[t])
    if (!vis[f]) dfs(f);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, y = 0;
    cin >> a;
    vector<int> v(a + 1, 0);
    for (int x = 0; x < a; x++) {
      int s;
      cin >> s;
      int flag = 0;
      while (s--) {
        int y;
        cin >> y;
        if (!v[y] && !flag) {
          v[y]++;
          flag++;
        }
      }
      if (!flag) y = x + 1;
    }
    if (!y)
      cout << "OPTIMAL";
    else {
      cout << "IMPROVE\n";
      for (int x = 1; x < v.size(); x++) {
        if (!v[x]) {
          cout << y << " " << x;
          break;
        }
      }
    }
    cout << endl;
  }
}
