#include <bits/stdc++.h>
using namespace std;
const unsigned long long l = 1000000007;
const int MAX_ = 2000;
int T;
void solve(int t) {
  long long n;
  cin >> n;
  vector<int> p[n];
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    p[i] = vector<int>(k);
    for (int j = 0; j < k; j++) {
      cin >> p[i][j];
    }
  }
  set<int> s;
  for (int i = 1; i <= n; i++) {
    s.insert(i);
  }
  int pos = -1;
  for (int i = 0; i < n; i++) {
    bool f = 0;
    for (int j = 0; j < p[i].size(); j++) {
      int x = p[i][j];
      if (s.find(x) != s.end()) {
        f = 1;
        s.erase(x);
        break;
      }
    }
    if (pos < 0 && f == 0) {
      pos = i + 1;
    }
  }
  if (pos > 0) {
    cout << "IMPROVE" << endl;
    cout << pos << " " << *s.begin() << endl;
    return;
  }
  cout << "OPTIMAL" << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, testCases;
  testCases = 1;
  while (testCases--) {
    t = 1;
    cin >> t;
    T = t;
    while (t--) {
      solve(t);
    }
  }
  return 0;
}
