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: //package com.company;
  
  
  
  import javax.naming.ldap.HasControls;
  import java.io.*;
  import java.util.*;
  
  public class Main implements Runnable {
      int size[];
      static int e9 = 1000000007;
      int max = Integer.MIN_VALUE;
      long max1 = Long.MIN_VALUE;
      long min1 = Long.MAX_VALUE;
      long fib[][];
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() {
              br = new BufferedReader(new
                      InputStreamReader(System.in));
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
      int parent[];
      int parent1[];
      int rank[];
      int rank1[];
      ArrayList<ArrayList<Integer>> arrayLists;
      long fib1[][];
      long r[];
      int n;
      int m;
      long co=0;
      int size1[];
      long v[];
      int arr[][];
      int u=0;
      HashMap<Long,Long> hashMap=new HashMap<>();
      ArrayList<Long> arrayList;
      long ans=0;
      public static void main(String[] args) throws IOException {
          new Thread(null,new Main(),"Main",1<<28).start();
      }
  
      public void run() {
          FastReader scanner = new FastReader();
  //            Scanner scanner = new Scanner(System.in);
  //            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
          PrintWriter printWriter = new PrintWriter(System.out);
          long t=1;
          high:while (t-- > 0) {
              int n=scanner.nextInt();
              int m1=scanner.nextInt();
              int m2=scanner.nextInt();
              parent(n+1);
              parent1(n+1);
              for (int i = 0; i < m1; i++) {
                  int u=scanner.nextInt();
                  int v=scanner.nextInt();
                  union(u,v);
  //                union(v,u);
              }
              for (int i = 0; i < m2; i++) {
                  int u=scanner.nextInt();
                  int v=scanner.nextInt();
                  union1(u,v);
  //                union(v,u);
              }
  //            for (int i = 1; i <=n; i++) {
  //                System.out.println(parent[i]+" "+parent1[i]);
  //            }
              int y=0;
              StringBuilder stringBuilder=new StringBuilder();
              for (int i = 1; i <=n; i++) {
                  for (int j = i+1; j <=n; j++) {
                      int a1=find(i), a2=find(j);
                      int b1=find1(i), b2=find1(j);
  
                      if(a1!=a2 && b1!=b2) {
                          union(a1, a2);
                          union1(b1, b2);
  
                          y++;
                          stringBuilder.append(i+" "+j+"\n");
  //                        result.add(i+" "+j);
                      }
                  }
              }
              printWriter.println(y);
              printWriter.println(stringBuilder.toString());
          }
          printWriter.flush();
      }
      static long mod=1_000_000_007;
      public long lcm(long a,long b){
          return (a*b)/gcd(a,b);
      }
      public long mul(long a, long b) {
  //        System.out.println(a+" "+b);
          return ((a)*(b));
      }
      public long fact(int x) {
          long ans=1;
          for (int i=2; i<=x; i++) ans=mul(ans, i);
          return ans;
      }
      public long fastPow(long base, long exp) {
          if (exp==0) return 1;
          long half=fastPow(base, exp/2);
          if (exp%2==0) return mul(half, half);
          return mul(half, mul(half, base));
      }
      public long modInv(long x) {
          return fastPow(x, mod-2);
      }
      public long nCk(int n, int k) {
          return mul(fact(n), mul(modInv(fact(k)), modInv(fact(n-k))));
      }
      public void parent(int n){
          parent=new int[n+1];
          size=new int[n+1];
          rank=new int[n+1];
          for (int i = 0; i <=n; i++) {
              parent[i]=i;
              rank[i]=0;
  //            size[i]=1;
          }
      }
      public void parent1(int n){
          parent1=new int[n+1];
          size1=new int[n+1];
          rank1=new int[n+1];
          for (int i = 0; i <=n; i++) {
              parent1[i]=i;
              rank1[i]=0;
  //            size[i]=1;
          }
      }
      public void union(int i,int j){
          int root1=find(i);
          int root2=find(j);
  //            if(root1 != root2) {
  //                parent[root2] = root1;
  ////                sz[a] += sz[b];
  //            }
          if(root1==root2){
              return;
          }
          if(rank[root1]>rank[root2]){
              parent[root2]=root1;
              size[root1]+=size[root2];
          }
          else if(rank[root1]<rank[root2]){
              parent[root1]=root2;
              size[root2]+=size[root1];
          }
          else{
              parent[root2]=root1;
              rank[root1]+=1;
              size[root1]+=size[root2];
          }
      }
      public void union1(int i,int j){
          int root1=find1(i);
          int root2=find1(j);
  //            if(root1 != root2) {
  //                parent[root2] = root1;
  ////                sz[a] += sz[b];
  //            }
          if(root1==root2){
              return;
          }
          if(rank1[root1]>rank1[root2]){
              parent1[root2]=root1;
              size1[root1]+=size1[root2];
          }
          else if(rank1[root1]<rank1[root2]){
              parent1[root1]=root2;
              size1[root2]+=size1[root1];
          }
          else{
              parent1[root2]=root1;
              rank1[root1]+=1;
              size1[root1]+=size1[root2];
          }
      }
      public int find(int p){
          if(parent[p]!=p){
              if(parent[p]==-1){
                  return parent[p];
              }
              parent[p]=find(parent[p]);
          }
          return parent[p];
      }
      public int find1(int p){
          if(parent1[p]!=p){
              if(parent1[p]==-1){
                  return parent1[p];
              }
              parent1[p]=find1(parent1[p]);
          }
          return parent1[p];
      }
      public double dist(double x1,double y1,double x2,double y2){
          double e=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
          double e1=Math.sqrt(e);
          return e1;
      }
      public void make(int p){
          parent[p]=p;
          rank[p]=1;
      }
      Random rand = new Random();
      public void sort(int[] a, int n) {
          for (int i = 0; i < n; i++) {
              int j = rand.nextInt(i + 1);
              int tmp = a[i];
              a[i] = a[j];
              a[j] = tmp;
          }
          Arrays.sort(a, 0, n);
      }
      public long gcd(long a,long b){
          if(b==0){
              return a;
          }
          return gcd(b,a%b);
      }
      //    public void dfs(ArrayList<Integer> arrayList){
  //        for (int i = 0; i < arrayList.size(); i++) {
  //            if(v1[arrayList.get(i)]==false){
  //                v1[arrayList.get(i)]=true;
  //                dfs(arrayLists.get(i));
  //            }
  //        }
  //    }
      public double fact(double h){
          double sum=1;
          while(h>=1){
              sum=(sum%e9)*(h%e9);
              h--;
          }
          return sum%e9;
      }
      public long primef(double r){
          long c=0;
          long ans=1;
          long g=0;
          while(r%2==0){
              c++;
              r=r/2;
          }
          if(c>0){
              ans*=2;
          }
          c=0;
  //            System.out.println(ans+" "+r);
          for (int i = 3; i <=Math.sqrt(r) ;i+=2) {
              g=0;
              while(r%i==0){
  //                    System.out.println(i);
                  c++;
                  g++;
                  r=r/i;
              }
              if(c>0){
                  ans*=i;
              }
              c=0;
          }
          if(r>2){
              ans*=r;
          }
          return ans;
      }
      public long divisor(double r){
          long c=0;
  //        if(n==3)
  //            System.out.println(r+" "+n+" "+k+" "+"l");
          for (int i =2; i <=Math.sqrt(r); i++) {
              if(r%i==0){
                  if(r/i==i){
                      c++;
                  }
                  else{
                      if(r/i<n){
                          c+=2;
                      }else{
                          c++;
                      }
                  }
              }
          }
          return c;
      }
  }
  class Pair {
      long x;
      long y;
      int z;
      public Pair(long x,long y) {
          this.x = x;
          this.y = y;
  //        this.z=z;
      }
  
  //     @Override
  //    public int hashCode() {
  //        int hash = 37;
  //        return this.x * hash + this.y;
  //    }
  //
  //    @Override
  //    public boolean equals(Object o1) {
  //        if (o1 == null || o1.getClass() != this.getClass()) {
  //            return false;
  //        }
  //        Pair o = (Pair) o1;
  //        if (o.x == this.x && o.y == this.y) {
  //            return true;
  //        }
  //        return false;
  //    }
  }
  class Sorting implements Comparator<Pair> {
      public int compare(Pair p1, Pair p2) {
          if(p1.x==p2.x){
              return Long.compare(p1.y,p2.y);
          }else {
              return Long.compare(p1.x, p2.x);
          }
      }
  }
  class Edge{
      int s=0;
      int d=0;
      int c=0;
      public Edge(int s,int d,int c){
          this.s=s;
          this.d=d;
          this.c=c;
      }
  }
  