#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    bool usa[n], usb[n];
    for (int i = 0; i < n; ++i) {
      usa[i] = 1;
      usb[i] = 1;
    }
    for (int i = 0; i < n; ++i) {
      int a;
      cin >> a;
      bool f = 1;
      for (int j = 0; j < a; j++) {
        int b;
        cin >> b;
        if (usb[b - 1] && f) {
          usb[b - 1] = 0;
          usa[i] = 0;
          f = 0;
        }
      }
    }
    bool c = 0, d = 0;
    int x, y;
    for (int i = 0; i < n; ++i) {
      if (usa[i] && !c) {
        x = i + 1;
        c = 1;
      }
      if (usb[i] && !d) {
        y = i + 1;
        d = 1;
      }
    }
    if (c)
      cout << "IMPROVE" << endl << x << " " << y << endl;
    else
      cout << "OPTIMAL" << endl;
  }
}
