#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  long long n;
  long long x;
  long long y;
  long long con;
  for (long long int i = 0; i < t; i++) {
    cin >> n;
    vector<bool> vis(n + 1, false);
    long long value = -1;
    for (long long int j = 0; j < n; j++) {
      cin >> x;
      con = 0;
      for (long long int k = 0; k < x; k++) {
        cin >> y;
        if (con == 0 && vis[y] == false) {
          vis[y] = true;
          con = 1;
        }
      }
      if (con == 0) value = j + 1;
    }
    if (value == -1)
      cout << "OPTIMAL" << '\n';
    else {
      cout << "IMPROVE" << '\n';
      for (long long int k = 1; k < n + 1; k++) {
        if (vis[k] == false) {
          cout << value << " " << k << '\n';
          break;
        }
      }
    }
  }
}
