#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int main() {
  int l;
  cin >> l;
  while (l--) {
    int n;
    cin >> n;
    map<int, bool> m;
    int index = -1;
    int maxm = 0;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      int minn = 1e9 + 7;
      for (int j = 0; j < x; ++j) {
        int y;
        cin >> y;
        if (!m[y]) minn = min(minn, y);
        maxm = max(maxm, y);
        if (!m[y]) m[y] = 0;
      }
      if (minn == 1e9 + 7) {
        index = i;
      }
      m[minn] = 1;
    }
    if (index == -1) {
      cout << "OPTIMAL\n";
    } else {
      cout << "IMPROVE\n";
      int ans = 1;
      for (int i = 1; i <= maxm + 1; ++i) {
        if (!m[i]) {
          ans = i;
          break;
        }
      }
      cout << index + 1 << " " << ans << "\n";
    }
  }
}
