#include <bits/stdc++.h>
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
const long double PI = 3.141592653589793;
const long long INF = 9223372036854775807ll;
const long long mod = 1e9 + 7;
void solve() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> take[n];
    int f = -1;
    vector<int> choose(n, 0);
    for (int i = 0; i < n; ++i) {
      int m;
      cin >> m;
      for (int j = 0; j < m; ++j) {
        int cur;
        cin >> cur;
        cur--;
        take[i].push_back(cur);
      }
    }
    for (int i = 0; i < n; ++i) {
      int g = 1;
      for (int j = 0; j < take[i].size(); ++j) {
        if (!choose[take[i][j]]) {
          choose[take[i][j]] = 1;
          g = 0;
          break;
        }
      }
      if (g) f = i;
    }
    if (f == -1)
      cout << "OPTIMAL" << '\n';
    else {
      cout << "IMPROVE" << '\n';
      for (int i = 0; i < n; ++i) {
        if (!choose[i]) {
          cout << (f + 1) << " " << (i + 1) << '\n';
          break;
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  solve();
  return 0;
}
