#include <bits/stdc++.h>
using namespace std;
long long int mod;
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
long long int m = 1e9 + 9, n, res, k, ans = 0, nbcycle = 0;
string s2 = "zero", ch = "", s;
set<long long int> st;
vector<pair<string, long long int> > vm;
vector<pair<long long int, pair<long long int, long long int> > > vvv;
vector<pair<long long int, long long int> > vv, vv2;
vector<long long int> v[100005];
long long int vis[10000005];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int i = 0, x = 0, y = 0, j = 0, z, q, nb0 = 0, nbp = 0, nbn = 0,
                nbmax = 0, nbinf = 0, mm = 5e8, idx = 0, ok = 0, l = 0, r = 0,
                negatif = 0, positif = 0, l1, r1, d;
  set<long long int>::iterator it, it1;
  char c;
  cin >> q;
  while (q--) {
    cin >> n;
    for (i = 1; i <= n; i++) {
      vis[i] = 0;
      v[i].clear();
    }
    for (i = 1; i <= n; i++) {
      cin >> k;
      for (j = 0; j < k; j++) {
        cin >> x;
        v[i].push_back(x);
      }
    }
    long long int princess = -1;
    for (i = 1; i <= n; i++) {
      if (v[i].size()) sort(v[i].begin(), v[i].end());
      long long int flag = 0;
      for (j = 0; j < v[i].size(); j++) {
        y = v[i][j];
        if (!vis[y]) {
          vis[y] = 1;
          flag = 1;
          break;
        }
      }
      if (!flag) princess = i;
    }
    if (princess == -1) {
      cout << "OPTIMAL\n";
      continue;
    }
    long long int prince = -1;
    for (i = 1; i <= n; i++)
      if (!vis[i]) {
        prince = i;
        break;
      }
    if (prince != -1) {
      cout << "IMPROVE\n" << princess << " " << prince << endl;
    }
  }
  return 0;
}
