#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const double PI = 3.141592653589793;
const long long INF = 1e16 + 7;
const int nax = 200005;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    vector<bool> vis(n + 1, 0);
    int unmarried = -1;
    for (int i = 1; i <= n; i++) {
      int k;
      cin >> k;
      bool married = false;
      while (k--) {
        int x;
        cin >> x;
        if (vis[x] == 0 && married == false) {
          vis[x] = 1;
          married = true;
        }
      }
      if (!married) unmarried = i;
    }
    if (unmarried == -1) {
      cout << "OPTIMAL"
           << "\n";
    } else {
      cout << "IMPROVE"
           << "\n";
      for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
          cout << unmarried << " " << i << "\n";
          break;
        }
      }
    }
  }
  return 0;
}
