#include <bits/stdc++.h>
using namespace std;
void addEdge(vector<int> adj[], int u, int v) { adj[u].push_back(v); }
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int x;
    int y;
    vector<int> adj[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> x;
      while (x--) {
        cin >> y;
        addEdge(adj, i, y);
      }
    }
    int b = 0, l = 0;
    bool visited[n + 1];
    for (int i = 1; i <= n; i++) visited[i] = false;
    bool f = false;
    for (int i = 1; i <= n; i++) {
      f = false;
      for (int j = 0; j < adj[i].size(); j++) {
        if (visited[adj[i][j]] == false) {
          visited[adj[i][j]] = true;
          f = true;
          break;
        }
      }
      if (f == false) b = i;
    }
    for (int i = 1; i <= n; i++) {
      if (visited[i] == false) {
        l = i;
        break;
      }
    }
    if (l && b) {
      cout << "IMPROVE" << endl;
      cout << b << " " << l;
    } else
      cout << "OPTIMAL";
    cout << endl;
  }
  return 0;
}
