#include <bits/stdc++.h>
using namespace std;
int T, N, K, a, x, y;
int main() {
  cin >> T;
  while (T--) {
    cin >> N;
    int suami[N + 1], istri[N + 1];
    memset(suami, 0, sizeof(suami));
    memset(istri, 0, sizeof(istri));
    for (int i = 1; i <= N; i++) {
      cin >> K;
      int a[K + 1];
      for (int j = 1; j <= K; j++) {
        cin >> a[j];
      }
      for (int j = 1; j <= K; j++) {
        if (istri[a[j]] == 0) {
          istri[a[j]] = i;
          suami[i] = a[j];
          break;
        }
      }
    }
    x = 0;
    y = 0;
    for (int i = 1; i <= N; i++) {
      if (suami[i] == 0) x = i;
      if (istri[i] == 0) y = i;
    }
    if (x == 0) {
      cout << "OPTIMAL" << endl;
    } else {
      cout << "IMPROVE" << endl;
      cout << x << " " << y << endl;
    }
  }
}
