#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long long int MX = 200000000000000;
long long int INF = 1e17;
long long int t, n, k;
long long int v[100100];
long long int ans[100100];
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) v[i] = ans[i] = 0;
    for (int i = 1; i <= n; i++) {
      cin >> k;
      int x;
      for (int j = 1; j <= k; j++) {
        cin >> x;
        if (!v[x] && ans[i] == 0) {
          v[x] = 1;
          ans[i] = x;
        }
      }
    }
    long long int st = -1;
    for (int i = 1; i <= n; i++)
      if (ans[i] == 0) st = i;
    long long int en = -1;
    for (int i = 1; i <= n; i++)
      if (v[i] == 0) en = i;
    if (st == -1)
      cout << "OPTIMAL\n";
    else {
      cout << "IMPROVE\n" << st << " " << en << endl;
    }
  }
  return 0;
}
