Problem: The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.

So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.

Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.

For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the n-th daughter.

For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3], [1, 2], [3, 4], [3], respectively.

<image>

In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of kingdom 3, leaving daughter 4 nobody to marry to.

Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.

Polycarp LXXXIV wants to increase the number of married couples.

Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.

If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.

For your and our convenience you are asked to answer t independent test cases.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.

Then t test cases follow.

The first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of daughters and the number of kingdoms.

Each of the next n lines contains the description of each daughter's list. The first integer k (0 ≤ k ≤ n) is the number of entries in the i-th daughter's list. After that k distinct integers follow g_i[1], g_i[2], ..., g_i[k] (1 ≤ g_i[j] ≤ n) — the indices of the kingdoms in the list in the increasing order (g_i[1] < g_i[2] < ... < g_i[k]).

It's guaranteed that the total number of daughters over all test cases does not exceed 10^5.

It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 10^5.

Output

For each test case print the answer to it.

Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers — the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list.

If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.

Otherwise the only line should contain one word "OPTIMAL".

Example

Input


5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4


Output


IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL

Note

The first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.

In the second test case any new entry will increase the number of marriages from 0 to 1.

In the third and the fourth test cases there is no way to add an entry.

In the fifth test case there is no way to change the marriages by adding any entry.

Solution (in JAVA):

Solution:

import java.io.*;
import java.io.IOException;
import java.util.*;
//import java.util.concurrent.LinkedBlockingDeque;

//import sun.net.www.content.audio.wav;

import java.text.DecimalFormat;
 
public class Codeforces {
	
	public static long mod = (long)Math.pow(10, 9)+7 ;
	public static double epsilon=0.00000000008854;//value of epsilon
	public static InputReader sc = new InputReader(System.in);
	public static PrintWriter pw = new PrintWriter(System.out);
	
	public static long gcd(long a,long b){
		while(b>0){
			long t=b;
			b=a%b;
			a=t;
		}
		return a;
	}
	public static int firstNode(int a,int p[]){
		if(a!=p[a]){
			p[a]=firstNode(p[a], p);
		}
		return p[a];
	}
	public static void Union(int a,int b,int p[]){
		//int a=firstNode(a1, p);
		//int b=firstNode(b1, p);
		/*if(a!=b){
			if(r[a]<r[b]){
				p[a]=b;
			}
			else if(r[a]>r[b]){
				p[b]=a;
			}
			else{
				r[b]++;
				p[a]=b;
			}
		}*/
		//if(a!=b)
		p[firstNode(a,p)]=firstNode(b,p);//if no rank than 
	}
	public static int countSet(int a){
		int c=0;
		while(a>0){
			a&=(a-1);
			c++;
		}
		return c;
	}

	public static int dis(int i,int d[],int p[]){
		if(d[i]!=0){
			return d[i];
		}
		else if(p[i]==-1){
			return d[i]=1;
		}
		else return d[i]=1+dis(p[i], d, p);
	}

	public static int hieght(int r,int h[],ArrayList<ArrayList <Integer>> a,int vis[],int p[]){//bottom Up
		vis[r]=1;
		for(int i=0;i<a.get(r).size();i++){
			int v=a.get(r).get(i);
			if(vis[v]==0){
				p[v]=r;
				h[r]=Math.max(h[r], hieght(v, h, a, vis,p));
			}
		}
		return ++h[r];
	}
	public static void hieghtBfs(int r,int h[],ArrayList<ArrayList <Integer>> a,int p[],int vis[]){/// top to bottom
		Deque<Integer> q=new LinkedList<>();
		q.add(r);
		int c=1;
		p[r]=-1;
		vis[r]=1;
		while(q.size()>0){
			int l=q.size();
			while(l-->0){
				int v=q.remove();
				h[v]=c;
				for(int i=0;i<a.get(v).size();i++){
					int u=a.get(v).get(i);
					if(vis[u]==0){
						p[u]=v;
						vis[u]=1;
						q.add(u);
					}
				}
			}
			c++;
		}
	}
	public static void centerTree(ArrayList<ArrayList<Integer>> a){
		int n=a.size();
		int d[]=new int[n];
		int vis[]=new int[n];
		Deque<Integer> q= new LinkedList<>();
		for(int i=0;i<n;i++){
			d[i]=a.get(i).size();
			if(d[i]==1)
			{
				vis[i]=1;
				q.add(i);
				//d[i]=0;
			}
		}
		//pw.println(Arrays.toString(d));
		//Deque<Integer> center=new LinkedList<>();
		int rc=0;
		while(q.size()>0){
			
			if(rc+q.size()==n)
			break;
			int l=q.size();
			while(l-->0){
				int v=q.remove();
				//pw.print(v+" ");
				rc++;
				for(int i=0;i<a.get(v).size();i++){
					int u=a.get(v).get(i);
					d[u]--;
					if(d[u]==1){
						q.add(u);
						//d[u]=0;
					}
				}
			}
			//pw.print("\n");
		}

		while(q.size()>0){
			pw.println(q.remove());
		}
		
	}
	public static int[] GetLps(String s){
		int n=s.length();
		int a[]=new int[n];
		int j=0;
		for(int i=1;i<n;i++){
			if(s.charAt(i)==s.charAt(j)){
				j++;
				a[i]=j;
			}
			else if(j>0){
				while(j>0&&s.charAt(i)!=s.charAt(j)){
					j=a[--j];
				}
				if(s.charAt(i)==s.charAt(j))
				a[i]=++j;
			}
		}
		//pw.println(Arrays.toString(a));

		return a;

	}
	public static long fun(int a[],int m,int n,int i,long c[],int t,long dp[][][]){
		if(n<0)
		return 0;
		
		if(dp[m][n][i]>0)
		return dp[m][n][i];
		
		if(m-a[n]==0){
			
			//c[0]+=((long)a.length-i)*((long)n+1);
			//c[0]%=998244353;
			dp[m][n][i]+=((long)a.length-i)*((long)n+1);
		}
		else if(m-a[n]>0){
			dp[m][n][i]+=fun(a, m-a[n], n-1, i, c, t,dp);
		}
		if(t==m)
		dp[m][n][i]+=fun(a, m, n-1, i-1, c,t,dp);
		else dp[m][n][i]+=fun(a, m, n-1, i, c, t,dp);
		return dp[m][n][i]%998244353;
		
	}
	public static String treeCode(int r,ArrayList<ArrayList<Integer>> a,int vis[]){
		String s="";
		vis[r]=1;
		ArrayList<String> l=new ArrayList<>();
		for(int i=0;i<a.get(r).size();i++){
			int u=a.get(r).get(i);
			if(vis[u]==0)
			l.add(treeCode(u, a, vis));
		}
		Collections.sort(l);
		for(int i=0;i<l.size();i++){
			s+=l.get(i);
		}
		return "("+s+")";
	}
	public static int daimeterUtil(int r,ArrayList<ArrayList <Integer>> a,int h[],int vis[]){
		vis[r]=1;
		int m1=0,m2=0,d=0;
		for(int i=0;i<a.get(r).size();i++){
			int u=a.get(r).get(i);
			if(vis[u]!=1){
				if(h[u]>m1){
					m2=m1;
					m1=h[u];
				}
				else if(h[u]>m2){
					m2=h[u];
				}
			}
		}
		d=Math.max(1+m1+m2, d);
		for(int i=0;i<a.get(r).size();i++){
			int u=a.get(r).get(i);
			if(vis[u]!=1){
				d=Math.max(daimeterUtil(u, a, h, vis), d);
			}
		}
		return d;

	}
	public static int daimeter(int r,ArrayList<ArrayList <Integer>> a){
		int n=a.size();
		int h[]=new int[n];
		int p[]=new int[n];
		hieght(r, h, a, new int[n], p);
		return daimeterUtil(r, a, h, new int[n]);
	}

	public static void main(String[] args) {
		// code starts..
		int q=sc.nextInt();
		while(q-->0){
			int n=sc.nextInt();
			ArrayList<ArrayList<Integer>> a=new ArrayList<>();
			for(int i=0;i<n;i++){
				a.add(new ArrayList<>());
				int k=sc.nextInt();
				for(int j=0;j<k;j++)
				a.get(i).add(sc.nextInt());
			}
			HashSet<Integer> h=new HashSet<>();
			int visk[]=new int [n];
			int visg[]=new int [n];
			for(int i=0;i<n;i++){
				for(int j=0;j<a.get(i).size();j++){
					
					int v=a.get(i).get(j);
					//pw.println(v);
					if(!h.contains(v)){
						h.add(v);
						visk[v-1]=1;
						visg[i]=1;
						break;
					}
				}
			}
			int notk=0,notg=0;
			for(int i=0;i<n;i++){
				if(visk[i]==0)
				notk=i+1;
				if(visg[i]==0)
				notg=i+1;
			}
			if(notk>0){
				pw.println("IMPROVE");
				pw.println(notg+" "+notk);
			}
			else pw.println("OPTIMAL");
		}

		



		// Code ends...
		pw.flush();
		pw.close();
	}
	public static Comparator<Integer> C(){
		return 
		new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o2.compareTo(o1);//for descending
			}
		};
	}
	static class tripletL implements Comparable<tripletL> {
		Long x, y, z;
 
		tripletL(long x, long y, long z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}
 
		public int compareTo(tripletL o) {
			int result = x.compareTo(o.x);
			if (result == 0)
				result = y.compareTo(o.y);
			if (result == 0)
				result = z.compareTo(o.z);
 
			return result;
		}
 
		public boolean equlas(Object o) {
			if (o instanceof tripletL) {
				tripletL p = (tripletL) o;
				return (x - p.x == 0) && (y - p.y ==0 ) && (z - p.z == 0);
			}
			return false;
		}
 
		public String toString() {
			return x + " " + y + " " + z;
		}
 
		public int hashCode() {
			return new Long(x).hashCode() * 31 + new Long(y).hashCode() + new Long(z).hashCode();
		}
	}
	public static String Doubleformate(double a,int n){
		String s="";
		while(n-->0){
			s+='0';
		}
		DecimalFormat f =new DecimalFormat("#0."+s);
		return f.format(a);
	}
 
	public static Comparator<Integer[]> column(int i){
		return 
		new Comparator<Integer[]>() {
			@Override
			public int compare(Integer[] o1, Integer[] o2) {
				return o1[i].compareTo(o2[i]);//for ascending
				//return o2[i].compareTo(o1[i]);//for descending
			}
		};
	}
	public static Comparator<Integer[]> pair(){
		return 
		new Comparator<Integer[]>() {
			@Override
			public int compare(Integer[] o1, Integer[] o2) {
				int result=o1[0].compareTo(o2[0]);
				if(result==0)
				result=o1[1].compareTo(o2[1]);
				return result;
			}
		};
	}
	public static Comparator<Integer[]> Triplet(){
		return 
		new Comparator<Integer[]>() {
			@Override
			public int compare(Integer[] o1, Integer[] o2) {
			
					for(int i=0;i<3;i++){
						for(int j=i+1;j<3;j++){
							for(int k=0;k<3;k++){
								for(int p=k+1;p<3;p++){
									if((o1[i]==o2[k]&&o1[j]==o2[p])||(o1[j]==o2[k]&&o1[i]==o2[p])){
 
									}
								}
							}
						}
					}
					int result=o1[0].compareTo(o2[0]);
					if(result==0)
					result=o1[1].compareTo(o2[1]);
					if(result==0)
					result=o1[2].compareTo(o2[2]);
					return result;
			}
		};
	}
	
	
	public static String reverseString(String s){
		StringBuilder input1 = new StringBuilder(); 
        input1.append(s);  
		input1 = input1.reverse();
		return input1.toString();
	}
	public static int[] scanArray(int n){
		int a[]=new int [n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextInt();
 
		return a;
	}
	public static long[] scanLongArray(int n){
		long a[]=new long [n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextLong();
 
		return a;
	}
	public static String [] scanStrings(int n){
		String a[]=new String [n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextLine();
 
		return a;
	}
	static class InputReader {
 
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;
 
		public InputReader(InputStream stream) {
			this.stream = stream;
		}
 
		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
 
		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
 
		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}
 
		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}
 
		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
 
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
 
		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
 
}

class Bit{//1...n
	int a[];
	Bit(int n){
		a=new int[n+1];
	}
	void update(int i,int delta){
		while(i<a.length){
			a[i]+=delta;
			i+=i&(-i);
		}
	}
	int query(int i){
		int sum=0;
		while(i>0){
			sum+=a[i];
			i-=i&(-i);
		}
		return sum;
	}
}
class Pair{
	int i,j;
	Pair(int i,int j){
		this.i=i;
		this.j=j;
	}
}