#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
map<int, int> mp, mp1;
int main() {
  int t;
  cin >> t;
  while (t--) {
    mp.clear();
    mp1.clear();
    int n;
    cin >> n;
    int k, x, ok = 0;
    for (int i = 1; i <= n; i++) {
      cin >> k;
      ok = 1;
      for (int j = 1; j <= k; j++) {
        cin >> x;
        if (!mp[x] && ok) {
          mp[x] = i;
          mp1[i] = x;
          ok = 0;
        }
      }
    }
    k = x = -1;
    for (int i = 1; i <= n; i++) {
      if (!mp[i]) {
        k = i;
        break;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (!mp1[i]) {
        x = i;
        break;
      }
    }
    if (x == -1 || k == -1)
      cout << "OPTIMAL" << endl;
    else {
      cout << "IMPROVE" << endl;
      cout << x << " " << k << endl;
    }
  }
}
