#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, priority_queue<T> V) {
  os << "[ ";
  while (V.size() > 0) {
    os << V.top() << " ";
    V.pop();
  }
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class T, class R>
ostream& operator<<(ostream& os, map<T, R> V) {
  os << "[ ";
  for (auto v : V) os << "(" << v.first << ":" << v.second << ")";
  return os << "]";
}
template <class T, class R>
ostream& operator<<(ostream& os, pair<T, R> V) {
  return os << "(" << V.first << "," << V.second << ")";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << "T->";
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  cout << "T->";
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
clock_t clk = clock();
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long MOD1 = 998244353;
void solve() {
  int n;
  cin >> n;
  vector<priority_queue<int>> a(n + 1);
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    int k;
    cin >> k;
    for (int(j) = (0); (j) < (k); (j)++) {
      int p;
      cin >> p;
      a[i].push(-p);
    }
  }
  vector<bool> married_boy(n + 1);
  vector<bool> married_girl(n + 1);
  married_boy.assign(n + 1, false);
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    while (a[i].size() > 0 && married_boy[-a[i].top()] == 1) a[i].pop();
    if (a[i].size() > 0) {
      married_boy[-a[i].top()] = 1;
      married_girl[i] = 1;
    }
  }
  int umb = -1, umg = -1;
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    if (!married_girl[i]) {
      umg = i;
      break;
    }
  }
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    if (!married_boy[i]) {
      umb = i;
      break;
    }
  }
  if (umb >= 0 && umg >= 0) {
    cout << "IMPROVE\n" << umg << " " << umb << endl;
  } else {
    cout << "OPTIMAL\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(25);
  int nooftestcases;
  cin >> nooftestcases;
  for (int(i) = (0); (i) < (nooftestcases); (i)++) solve();
  return 0;
}
