#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    int pos = -1;
    cin >> n;
    long long i;
    int kings[n + 1];
    for (i = 1; i <= n; i++) {
      kings[i] = 0;
    }
    for (i = 0; i < n; i++) {
      long long k;
      cin >> k;
      int A[k];
      for (int j = 0; j < k; j++) {
        int value;
        cin >> value;
        A[j] = value;
      }
      int flag = 0;
      for (int j = 0; j < k; j++) {
        if (kings[A[j]] == 0) {
          kings[A[j]] = 1;
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        pos = i;
      }
    }
    if (pos == -1) {
      cout << "OPTIMAL" << endl;
    } else {
      int kingvalue;
      for (int i = 1; i <= n; i++) {
        if (kings[i] == 0) {
          kingvalue = i;
          break;
        }
      }
      cout << "IMPROVE" << endl;
      cout << pos + 1 << " " << kingvalue << endl;
    }
  }
  return 0;
}
