#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long test;
  cin >> test;
  while (test--) {
    long long n;
    cin >> n;
    vector<long long> usedB(n, -1), usedG(n, -1);
    for (int i = 0; i < n; i++) {
      long long k;
      cin >> k;
      for (int j = 0; j < k; j++) {
        long long x;
        cin >> x;
        x--;
        if (usedB[x] == -1 && usedG[i] == -1) {
          usedB[x] = i;
          usedG[i] = x;
        }
      }
    }
    long long check = -1;
    for (int i = 0; i < n; i++) {
      if (usedG[i] == -1) {
        check = i;
        break;
      }
    }
    if (check == -1) {
      cout << "OPTIMAL\n";
    } else {
      int ans = -1;
      for (int i = 0; i < n; i++) {
        if (usedB[i] == -1) {
          ans = i;
          break;
        }
      }
      cout << "IMPROVE\n" << check + 1 << ' ' << ans + 1 << '\n';
    }
  }
}
