#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
int tc, n, k;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  cin >> tc;
  while (tc--) {
    cin >> n;
    vector<int> a(n + 1, 0);
    vector<int> b(n + 1, 0);
    int cnt = 0;
    for (int i = 1; i <= (int)(n); ++i) {
      cin >> k;
      for (int j = 0; j < (int)(k); ++j) {
        int x;
        cin >> x;
        if (!a[i] && !b[x]) {
          ++cnt;
          a[i] = 1;
          b[x] = 1;
        }
      }
    }
    if (cnt == n)
      cout << "OPTIMAL" << '\n';
    else {
      int a1, a2;
      for (int i = 1; i <= (int)(n); ++i) {
        if (!a[i]) {
          a1 = i;
          break;
        }
      }
      for (int i = 1; i <= (int)(n); ++i) {
        if (!b[i]) {
          a2 = i;
          break;
        }
      }
      cout << "IMPROVE" << '\n';
      cout << a1 << ' ' << a2 << '\n';
    }
  }
  return 0;
}
