#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10, mod = 1e9 + 7;
long long n, m, t, k;
long long s[N], g[N], f[N];
int main() {
  cin >> t;
  while (t--) {
    int cnt = 0, a = 0, b;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> m;
      for (int j = 1; j <= m; j++) {
        cin >> b;
        if (g[i] == 0 && s[b] == 0) g[i] = 1, s[b] = 1, cnt++;
      }
      if (a == 0 && cnt != i) a = i;
    }
    if (cnt == n)
      puts("OPTIMAL");
    else {
      puts("IMPROVE");
      printf("%d ", a);
      for (int i = 1; i <= n; i++)
        if (s[i] == 0) {
          printf("%d\n", i);
          break;
        }
    }
    for (int i = 1; i <= n; i++) g[i] = s[i] = 0;
  }
  return 0;
}
