import java.io.*;
import java.util.*;

public class TestGen {

    static int done = 0;

    static final Random rand = new Random(556668949239L);
    
    static void print(int n, int[] a, int m, int[] l, int[] r) throws IOException  {
		done++;		
		System.err.println("Generation test #" + done);
		PrintWriter out;				
		if (done > 2) {
			if (done - 2 < 10)
	    		out = new PrintWriter("../tests/0" + String.valueOf(done - 2));
			else
	    		out = new PrintWriter("../tests/" + String.valueOf(done - 2));						
		}
		else {				
			if (done < 10)
	    		out = new PrintWriter("../preliminary/0" + String.valueOf(done));
			else
	    		out = new PrintWriter("../preliminary/" + String.valueOf(done));				
		}
		out.println(n);
		for (int i = 1; i <= n; ++i) {
			out.print(a[i]);
			if (i != n)
				out.print(' ');
		}
		out.println();
		out.println(m);		
		for (int i = 1; i <= m; ++i) 
			out.println(l[i] + " " + r[i]);
		out.println();						
		out.close();    
    }
        
    static int randFromTo(int from, int to) {
		return rand.nextInt(to - from + 1) + from;
    }        
    static void makeTest(int minN, int maxN, int minM, int maxM, int minA, int maxA) throws IOException {
    	int n = randFromTo(minN, maxN);
    	int m = randFromTo(minM, maxM);
    	int[] a = new int[n + 1];
    	int[] l = new int[m + 1];
    	int[] r = new int[m + 1];
    	for (int i = 1; i <= n; ++i)
    		a[i] = randFromTo(minA, maxA);    	
    	for (int i = 1; i <= m; ++i) {
    		r[i] = randFromTo(1, n);
    		l[i] = randFromTo(1, r[i]);    	
    	}    	
        print(n, a, m, l, r);
    }    
       
    static int power10(int exp) {
    	if (exp == 0)
    		return 1;
    	return power10(exp - 1) * 10;
    }

    public static void main(String[] args) throws IOException {
    	makeTest(4, 4, 4, 4, 2, 4); 	
		for (int i = 0; i < 1; ++i) 
			makeTest(5, 8, 10, 15, 1, 6);
		//Group1 n <= 15, m <= 15
		for (int i = 1; i <= 10; ++i)
			makeTest(i, 15, i, 15, 1, 6);
		makeTest(10, 15, 10, 15, 0, 0);
		makeTest(10, 15, 10, 15, 1000, 1000);
		
		//Group 2 n <= 1000, m <= 10000
		for (int i = 0; i < 5; ++i)
			makeTest(100, 1000, 100, 1000, 1, 1000);		
		for (int i = 0; i < 5; ++i)
			makeTest(1000, 1000, 1000, 1000, 500, 1000);
		for (int i = 0; i < 5; ++i)
			makeTest(1, 10, 500, 1000, 500, 1000);
		for (int i = 0; i < 5; ++i)
			makeTest(500, 1000, 1, 100, 1, 1000);

		//Group3 n <= 100000 m <= 100000
		for (int i = 0; i < 5; ++i)
			makeTest(100, 1000, 10000, 50000, 1, 50000);		
		for (int i = 0; i < 5; ++i)               	
			makeTest(1000, 10000, 100000, 100000, 1, 100000);
		for (int i = 0; i < 5; ++i)
			makeTest(100, 1000, 10000, 50000, power10(i), 50000);
		for (int i = 0; i < 5; ++i)
			makeTest(1000, 10000, 50000, 100000, power10(i), 100000);
		for (int i = 0; i < 5; ++i)
			makeTest(50000, 100000, 50000, 100000, 1, 100000);
		for (int i = 0; i < 5; ++i)
			makeTest(50000, 100000, 50000, 100000, power10(i), 100000); 
		makeTest(500, 1000, 50000, 100000, 100, 100000);
		makeTest(50000, 100000, 500, 1000, 100, 100000);							  				
		return;
    }
    static int min(int a, int b) {
    	if (a < b)
    		return a;
    	return b;
    }
    static int max(int a, int b) {
    	if (a > b)
    		return a;
    	return b;
    }    
}                               //1
