#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k, x;
    cin >> n;
    vector<vector<int>> a(n + 1);
    vector<int> mg(n + 1, 1), mb(n + 1, 1);
    for (long long i = 0; i < n; i++) {
      cin >> k;
      for (long long j = 0; j < k; j++) {
        cin >> x;
        a[i].push_back(x);
      }
    }
    for (long long i = 0; i < n; i++) {
      int k = (long long)(a[i].size());
      for (long long j = 0; j < k; j++) {
        x = a[i][j];
        if (mb[x] == 1) {
          mb[x] = 0;
          mg[i + 1] = 0;
          break;
        }
      }
    }
    long long g = -1, b = -1;
    for (long long i = 1; i < n + 1; i++)
      if (mb[i] == 1) b = i;
    for (long long i = 1; i < n + 1; i++)
      if (mg[i] == 1) g = i;
    if (b != -1) {
      cout << "IMPROVE\n";
      cout << g << " " << b << "\n";
    } else
      cout << "OPTIMAL\n";
  }
  return 0;
}
