#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using namespace std;
int mod = 1000000007;
int fact(int n) {
  int res = 1;
  for (int i = 2; i <= n; i++) {
    res = (res * 1ll * i) % mod;
  }
  return res;
}
int binpow(int x, int y) {
  int res = 1;
  x = x % mod;
  if (x == 0) return 0;
  while (y) {
    if (y % 2 == 1) res = (1ll * res * x) % mod;
    y = y >> 1;
    x = (1ll * x * x) % mod;
  }
  return res;
}
int C(int n, int k) {
  if (n < k) return 0;
  int ans = (1ll * fact(n) * binpow(fact(k), mod - 2)) % mod;
  ans = (ans * 1ll * binpow(fact(n - k), mod - 2)) % mod;
  return ans;
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return ((a.first > b.first) || (a.first == b.first && a.second < b.second));
}
int lowerIndex(vector<int> arr, int n, int x) {
  int l = 0, h = n - 1;
  while (l <= h) {
    int mid = (l + h) / 2;
    if (arr[mid] >= x)
      h = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
int upperIndex(vector<int> arr, int n, int y) {
  int l = 0, h = n - 1;
  while (l <= h) {
    int mid = (l + h) / 2;
    if (arr[mid] <= y)
      l = mid + 1;
    else
      h = mid - 1;
  }
  return h;
}
void solve() {
  int n, x;
  cin >> n;
  set<int> s;
  for (int i = 1; i <= n; i++) s.insert(i);
  int f = -1, idx = -1, val = -1, c = 0;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    f = 0;
    int cnt = 0;
    for (int j = 0; j < k; j++) {
      cin >> x;
      if (s.find(x) != s.end() && cnt == 0) {
        f = 1;
        s.erase(x);
        cnt++;
      }
    }
    if (f == 0 && c == 0) {
      idx = i;
      c = 1;
    }
  }
  if (c) val = *(s.begin());
  if (c)
    cout << "IMPROVE\n" << idx << " " << val << endl;
  else
    cout << "OPTIMAL" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
