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: """
        ___.   .__    .__       .__            __    __       _________ 
  _____ \_ |__ |  |__ |__| _____|  |__   ____ |  | _|  | __   \______  \
  \__  \ | __ \|  |  \|  |/  ___/  |  \_/ __ \|  |/ /  |/ /       /    /
   / __ \| \_\ \   Y  \  |\___ \|   Y  \  ___/|    <|    <       /    / 
  (____  /___  /___|  /__/____  >___|  /\___  >__|_ \__|_ \_____/____/  
       \/    \/     \/        \/     \/     \/     \/    \/_____/       
  """
  import sys, io, os
  
  BUFSIZE = 8192
  
  
  class FastIO(io.IOBase):
      newlines = 0
  
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = io.BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
  
      def read(self):
          while True:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
  
      def readline(self):
          while self.newlines == 0:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
  
      def flush(self):
          if self.writable:
              os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
  
  
  class IOWrapper(io.IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  def print(*args, **kwargs):
      """Prints the values to a stream, or to sys.stdout by default."""
      sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
      at_start = True
      for x in args:
          if not at_start:
              file.write(sep)
          file.write(str(x))
          at_start = False
      file.write(kwargs.pop("end", "\n"))
      if kwargs.pop("flush", False):
          file.flush()
  
  
  sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  # endregion
  MOD = 1000000007
  
  
  from collections import defaultdict as dd,Counter,deque
  def si(): return input()
  
  
  def ii(): return int(input())
  
  
  def li(): return list(map(int, input().split()))
  
  
  def mi(): return map(int, input().split())
  
  
  def sout(v): print(v, end=' ')
  
  
  def d2b(n): return bin(n).replace("0b", "")
  
  
  def twod(n, m, num): return [[num for x in range(m)] for y in range(n)]
  
  
  def vow(): return ['a', 'e', 'i', 'o', 'u']
  
  
  def let(): return [chr(i) for i in range(97, 123)]
  
  
  def gcd(x, y):
      while y:
          x, y = y, x % y
      return x
  
  
  def ispow2(x):
      return (x and (not (x & (x - 1))))
  
  
  def prime_factors(n):
      i = 2
      factors = []
      while i * i <= n:
          if n % i:
              i += 1
          else:
              n //= i
              factors.append(i)
      if n > 1: factors.append(n)
      return (list(factors))
  
  
  def binary_search(arr, low, high, x):
      if high >= low:
          mid = (high + low) // 2
          if arr[mid] == x:
              return mid
          elif arr[mid] > x:
              return binary_search(arr, low, mid - 1, x)
          else:
              return binary_search(arr, mid + 1, high, x)
      else:
          return -1
  
  
  def sieve(n):
      primes = []
      least_prime_divs = [0] * (n + 1)
      for i in range(2, n + 1):
          if not least_prime_divs[i]:
              least_prime_divs[i] = i
              primes.append(i)
          for p in primes:
              if i * p > n or p > least_prime_divs[i]: break
              least_prime_divs[i * p] = p
      return primes
  
  def parent(per,vis,par,arr):
      for i in range(1,n+1):
          if not vis[i]:
              arr[0]=1
              dfs(per,vis,i,par,i,arr)
              par[i]=-1*arr[0]
  
  def dfs(g,vis,s,par,source,arr):
      vis[s]=True
      for i in g[s]:
          if not vis[i]:
              par[i]=source
              arr[0]+=1
              dfs(g,vis,i,par,source,arr)
  
  def Find(node,par):
      if par[node]<0: return node
      a= Find(par[node],par)
      return a
  
  def Union(par,node,mainParent):
      par[mainParent]+=par[node]
      par[node]=mainParent
  
  n,m1,m2=mi()
  mo=dd(list)
  di=dd(list)
  vism=[False for _ in range(n+1)]
  visd=[False for _ in range(n+1)]
  parm=[-1 for _ in range(n+1)]
  pard=[-1 for _ in range(n+1)]
  for _ in range(m1):
      x,y=mi()
      mo[x].append(y)
      mo[y].append(x)
  for _ in range(m2):
      x,y=mi()
      di[x].append(y)
      di[y].append(x)
  arr=[1]
  parent(mo,vism,parm,arr)
  parent(di,visd,pard,arr)
  ans=[]
  for i in range(1,n+1):
      for j in range(i+1,n+1):
          # print(i,j,parm,"mochoa")
          par1=Find(i,parm)
          par2=Find(j,parm)
          if parm[i]>0: parm[i]=par1
          if parm[j]>0: parm[j]=par2
          if par1!=par2:
              # print(i,j,pard,"Diana")
              par3=Find(i,pard)
              par4=Find(j,pard)
              if pard[i]>0: pard[i]=par3
              if pard[j]>0: pard[j]=par4
              if par3!=par4:
                  ans.append([i,j])
                  # print(ans)
                  # print(parm, "Mochoaaaaa Before",i,j)
                  # print(pard, "Dianaaaaaa Before")
                  if abs(parm[par1])>abs(parm[par2]):
                      Union(parm,par2,par1)
                  else:
                      Union(parm,par1,par2)
                  if abs(pard[par3])>abs(pard[par4]):
                      Union(pard,par4,par3)
                  else:
                      Union(pard,par3,par4)
                  # print(parm,"Mochoaaaaa")
                  # print(pard,"Dianaaaaaa")
  print(len(ans))
  for i in range(len(ans)):
      print(*ans[i])
  