description: This is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
  
  A forest is an undirected graph without cycles (not necessarily connected).
  
  Mocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: 
  
    * After adding edges, both of their graphs are still forests. 
    * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. 
  
  
  
  Mocha and Diana want to know the maximum number of edges they can add, and which edges to add.
  
  Input
  
  The first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 1000, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.
  
  Each of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.
  
  Each of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.
  
  Output
  
  The first line contains only one integer h, the maximum number of edges Mocha and Diana can add (in each forest).
  
  Each of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.
  
  If there are multiple correct answers, you can print any one of them.
  
  Examples
  
  Input
  
  
  3 2 2
  1 2
  2 3
  1 2
  1 3
  
  
  Output
  
  
  0
  
  
  Input
  
  
  5 3 2
  5 4
  2 1
  4 3
  4 3
  1 4
  
  
  Output
  
  
  1
  2 4
  
  
  Input
  
  
  8 1 2
  1 7
  2 6
  1 5
  
  
  Output
  
  
  5
  5 2
  2 3
  3 4
  4 7
  6 8
  
  Note
  
  In the first example, we cannot add any edge.
  
  In the second example, the initial forests are as follows.
  
  <image>
  
  We can add an edge (2, 4).
  
  <image>
solution: 
  
  import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.ArrayList;
  
  
  
  public class disjoint {
  	 static class Reader {
  		 
  	        final private int BUFFER_SIZE = 1 << 16;
  	        private DataInputStream din;
  	        private byte[] buffer;
  	        private int bufferPointer, bytesRead;
  	 
  	        public Reader()
  	        {
  	            din = new DataInputStream(System.in);
  	            buffer = new byte[BUFFER_SIZE];
  	            bufferPointer = bytesRead = 0;
  	        }
  	 
  	        public Reader(String file_name) throws IOException
  	        {
  	            din = new DataInputStream(
  	                new FileInputStream(file_name));
  	            buffer = new byte[BUFFER_SIZE];
  	            bufferPointer = bytesRead = 0;
  	        }
  	 
  	        public String readLine() throws IOException
  	        {
  	            byte[] buf = new byte[64]; // line length
  	            int cnt = 0, c;
  	            while ((c = read()) != -1) {
  	                if (c == '\n') {
  	                    if (cnt != 0) {
  	                        break;
  	                    }
  	                    else {
  	                        continue;
  	                    }
  	                }
  	                buf[cnt++] = (byte)c;
  	            }
  	            return new String(buf, 0, cnt);
  	        }
  	 
  	        public int nextInt() throws IOException
  	        {
  	            int ret = 0;
  	            byte c = read();
  	            while (c <= ' ') {
  	                c = read();
  	            }
  	            boolean neg = (c == '-');
  	            if (neg)
  	                c = read();
  	            do {
  	                ret = ret * 10 + c - '0';
  	            } while ((c = read()) >= '0' && c <= '9');
  	 
  	            if (neg)
  	                return -ret;
  	            return ret;
  	        }
  	 
  	        public long nextLong() throws IOException
  	        {
  	            long ret = 0;
  	            byte c = read();
  	            while (c <= ' ')
  	                c = read();
  	            boolean neg = (c == '-');
  	            if (neg)
  	                c = read();
  	            do {
  	                ret = ret * 10 + c - '0';
  	            } while ((c = read()) >= '0' && c <= '9');
  	            if (neg)
  	                return -ret;
  	            return ret;
  	        }
  	 
  	        public double nextDouble() throws IOException
  	        {
  	            double ret = 0, div = 1;
  	            byte c = read();
  	            while (c <= ' ')
  	                c = read();
  	            boolean neg = (c == '-');
  	            if (neg)
  	                c = read();
  	 
  	            do {
  	                ret = ret * 10 + c - '0';
  	            } while ((c = read()) >= '0' && c <= '9');
  	 
  	            if (c == '.') {
  	                while ((c = read()) >= '0' && c <= '9') {
  	                    ret += (c - '0') / (div *= 10);
  	                }
  	            }
  	 
  	            if (neg)
  	                return -ret;
  	            return ret;
  	        }
  	 
  	        private void fillBuffer() throws IOException
  	        {
  	            bytesRead = din.read(buffer, bufferPointer = 0,
  	                                 BUFFER_SIZE);
  	            if (bytesRead == -1)
  	                buffer[0] = -1;
  	        }
  	 
  	        private byte read() throws IOException
  	        {
  	            if (bufferPointer == bytesRead)
  	                fillBuffer();
  	            return buffer[bufferPointer++];
  	        }
  	 
  	        public void close() throws IOException
  	        {
  	            if (din == null)
  	                return;
  	            din.close();
  	        }
  	 }
  	static class DisjointUnionSets {
  	    int[] rank, parent;
  	    int n;
  	  
  	    // Constructor
  	    public DisjointUnionSets(int n)
  	    {
  	        rank = new int[n];
  	        parent = new int[n];
  	        this.n = n;
  	        makeSet();
  	    }
  	  
  	    // Creates n sets with single item in each
  	    void makeSet()
  	    {
  	        for (int i = 0; i < n; i++) {
  	            // Initially, all elements are in
  	            // their own set.
  	            parent[i] = i;
  	        }
  	    }
  	  
  	    // Returns representative of x's set
  	    int find(int x)
  	    {
  	        // Finds the representative of the set
  	        // that x is an element of
  	        if (parent[x] != x) {
  	            // if x is not the parent of itself
  	            // Then x is not the representative of
  	            // his set,
  	            parent[x] = find(parent[x]);
  	  
  	            // so we recursively call Find on its parent
  	            // and move i's node directly under the
  	            // representative of this set
  	        }
  	  
  	        return parent[x];
  	    }
  	  
  	    // Unites the set that includes x and the set
  	    // that includes x
  	    void union(int x, int y)
  	    {
  	        // Find representatives of two sets
  	        int xRoot = find(x), yRoot = find(y);
  	  
  	        // Elements are in the same set, no need
  	        // to unite anything.
  	        if (xRoot == yRoot)
  	            return;
  	  
  	        // If x's rank is less than y's rank
  	        if (rank[xRoot] < rank[yRoot])
  	  
  	            // Then move x under y  so that depth
  	            // of tree remains less
  	            parent[xRoot] = yRoot;
  	  
  	        // Else if y's rank is less than x's rank
  	        else if (rank[yRoot] < rank[xRoot])
  	  
  	            // Then move y under x so that depth of
  	            // tree remains less
  	            parent[yRoot] = xRoot;
  	  
  	        else // if ranks are the same
  	        {
  	            // Then move y under x (doesn't matter
  	            // which one goes where)
  	            parent[yRoot] = xRoot;
  	  
  	            // And increment the result tree's
  	            // rank by 1
  	            rank[xRoot] = rank[xRoot] + 1;
  	        }
  	    }
  	}
  	
  	public static void main(String[] args) throws IOException {
  		// TODO Auto-generated method stub
  		Reader reader = new Reader();
  		//Scanner reader=new Scanner(System.in);
  		//BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
  		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		//int cases=Integer.parseInt(br.readLine());
  		int cases=1;
  		//int cases=reader.nextInt();
  
     	while (cases-->0){
     		//maxheap x=new maxheap();
     		int N=reader.nextInt();
     		int M=reader.nextInt();
     		int K=reader.nextInt();
     		
     		//long K=reader.nextLong();
     		//PriorityQueue<Long> Q = new PriorityQueue<Long>();
     		//int S=reader.nextInt();
     		//int circum=reader.nextInt();
     		//int K=reader.nextInt();
     		//int N=Integer.parseInt(br.readLine());
     		//String[] first=br.readLine().split(" ");
     		//int N=Integer.parseInt(first[0]);
     		//int K=Integer.parseInt(first[1]);
     		//int X=reader.nextInt();
     		//int Y=reader.nextInt();
     		//String str1=br.readLine();
     		//char[] str11=str1.toCharArray();
     		//String str2=br.readLine();
     		//int max=Integer.MIN_VALUE;
     		//int min=Integer.MAX_VALUE;
     		//HashMap<Integer,Integer > map=new HashMap<Integer,Integer>();
     		//TreeSet<Integer> map=new TreeSet<Integer>();
     		//HashSet<Integer> map=new HashSet<Integer>();
     		//int[] arr=new int[N+1];
     		//int [][] arr1=new int[N][2];
     		//long[]arr=new long[N];
     		//arrInpInt(arr,N);
     		//arrInpLong(arr,N);
     		//int[] arr1=decSort(arr);
     		//printArr(arr1);
     		//System.out.println(arr[N]);
     		//String fin=strip()
     		//long row=(long) Math.sqrt(N);
     		//System.out.println(row);
     		//System.out.println(str1+" "+str2);
     	 DisjointUnionSets G1 = new DisjointUnionSets(N);
     	 DisjointUnionSets G2 = new DisjointUnionSets(N);
     	 for(int i=0;i<M;i++)
     	 {
     		 G1.union(reader.nextInt()-1, reader.nextInt()-1);
     	 }
     	 for(int i=0;i<K;i++)
     	 {
     		 G2.union(reader.nextInt()-1, reader.nextInt()-1);
     	 }
     	 int tot=0;
     	 ArrayList<String> k=new ArrayList<String>();
     	 for(int i=0;i<N;i++)
     	 {
     		 for(int j=0;j<N;j++)
     		 {
     			 if(G1.find(i)!=G1.find(j) && G2.find(i)!=G2.find(j))
     			 {
     				tot++;
     				k.add(""+(i+1)+" "+(j+1));
     				G1.union(i, j);
     				G2.union(i, j);
     				
     			 }
     		 }
     		 
     	 }
     	 System.out.println(tot);
     	 for(int i=0;i<k.size();i++)
     	 {
     		 System.out.println(k.get(i));
     	 }
     		
     	}
  
  	}
  
  }
  