#include <bits/stdc++.h>
int freq[1000000];
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t, n, k, x, a, b;
  cin >> t;
  while (t--) {
    cin >> n;
    int m = 0;
    a = 0;
    for (int i = 1; i <= n; i++) {
      cin >> k;
      int l = 0;
      for (int j = 0; j < k; j++) {
        cin >> x;
        if (freq[x] == 0 && l == 0) {
          l++;
          freq[x]++;
        }
      }
      if (m == 0 && l == 0) {
        m = i;
      }
    }
    if (m) {
      for (int i = 1; i <= n; i++) {
        if (freq[i] == 0) {
          a = m;
          b = i;
          break;
        }
      }
    }
    if (a == 0) {
      cout << "OPTIMAL" << endl;
    } else {
      cout << "IMPROVE" << endl;
      cout << a << " " << b << endl;
    }
    for (int i = 1; i <= n; i++) freq[i] = 0;
  }
}
