#include <bits/stdc++.h>
using namespace std;
namespace InputOutput {
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
  out << p.first << ' ' << p.s << "   ";
  return out;
}
template <class T1, class T2>
istream& operator>>(istream& inp, pair<T1, T2>& p) {
  inp >> p.first >> p.s;
  return inp;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& p) {
  for (auto& el : p) {
    out << el << '\n';
  }
  return out;
}
template <typename T>
istream& operator>>(istream& inp, vector<T>& p) {
  for (auto& el : p) {
    inp >> el;
  }
  return inp;
}
template <typename T>
ostream& operator<<(ostream& out, deque<T>& p) {
  for (auto& el : p) {
    out << el << ' ';
  }
  return out;
}
template <typename T>
istream& operator>>(istream& inp, deque<T>& p) {
  for (auto& el : p) {
    inp >> el;
  }
  return inp;
}
}  // namespace InputOutput
using namespace InputOutput;
vector<vector<long long> > a;
vector<bool> used;
signed main() {
  ios_base::sync_with_stdio(false);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t;
  cin >> t;
  while (t--) {
    long long n, i, j;
    cin >> n;
    a.resize(n);
    for (i = 0; i < n; ++i) {
      long long k;
      cin >> k;
      a[i].resize(k);
      for (j = 0; j < k; ++j) {
        cin >> a[i][j];
        a[i][j]--;
      }
    }
    used.resize(n, false);
    long long tyan = -1;
    for (i = 0; i < n; ++i) {
      for (j = 0; j < a[i].size(); ++j)
        if (!used[a[i][j]]) {
          used[a[i][j]] = true;
          break;
        }
      if (j == a[i].size()) tyan = i;
    }
    if (tyan == -1)
      cout << "OPTIMAL\n";
    else {
      for (i = 0; i < n; ++i)
        if (!used[i]) {
          cout << "IMPROVE\n";
          cout << tyan + 1 << ' ' << i + 1 << '\n';
          break;
        }
    }
    a.clear();
    used.clear();
  }
  return 0;
}
