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: # ///////////////////////////////////////////////////////////////////////////
  # //////////////////// PYTHON IS THE BEST ////////////////////////
  # ///////////////////////////////////////////////////////////////////////////
  import sys,os,io
  from sys import stdin
  import math 
  from collections import defaultdict
  from heapq import heappush, heappop, heapify
  from bisect import bisect_left , bisect_right
  from io import BytesIO, IOBase
  BUFSIZE = 8192
  
  class FastIO(IOBase):
      newlines = 0
  
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = 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(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")
  
  
  
  
  alphabets = list('abcdefghijklmnopqrstuvwxyz')
  
  
  
  #for deep recursion__________________________________________-
  from types import GeneratorType
  def bootstrap(f, stack=[]):
      def wrappedfunc(*args, **kwargs):
          if stack:
              return f(*args, **kwargs)
          else:
              to = f(*args, **kwargs)
              while True:
                  if type(to) is GeneratorType:
                      stack.append(to)
                      to = next(to)
                  else:
                      stack.pop()
                      if not stack:
                          break
                      to = stack[-1].send(to)
              return to
  
      return wrappedfunc
  
  def ncr(n, r, p):  
      num = den = 1
      for i in range(r):
          num = (num * (n - i)) % p
          den = (den * (i + 1)) % p
      return (num * pow(den,p - 2, p)) % p
  
  def primeFactors(n): 
      l = []
      while n % 2 == 0: 
          l.append(2)
          n = n / 2
      for i in range(3,int(math.sqrt(n))+1,2): 
          while n % i== 0: 
              l.append(int(i))
              n = n / i 
      if n > 2: 
          l.append(n)
      # c = dict(Counter(l))
      return list(set(l))
      # return c
  
  def power(x, y, p) : 
  	res = 1
  	x = x % p 
  	if (x == 0) : 
  		return 0
  	while (y > 0) : 
  		if ((y & 1) == 1) : 
  			res = (res * x) % p 
  		y = y >> 1	 # y = y/2 
  		x = (x * x) % p 		
  	return res 
  
  #____________________GetPrimeFactors in log(n)________________________________________
  def sieveForSmallestPrimeFactor():
      MAXN = 100001
      spf = [0 for i in range(MAXN)]
      spf[1] = 1
      for i in range(2, MAXN):
          spf[i] = i
      for i in range(4, MAXN, 2):
          spf[i] = 2
      for i in range(3, math.ceil(math.sqrt(MAXN))):
          if (spf[i] == i):
              for j in range(i * i, MAXN, i): 
                  if (spf[j] == j):
                      spf[j] = i
      return spf
  def getPrimeFactorizationLOGN(x):
      spf = sieveForSmallestPrimeFactor()
      ret = list()
      while (x != 1):
          ret.append(spf[x])
          x = x // spf[x]  
      return ret
  #____________________________________________________________
  
  
  
  def SieveOfEratosthenes(n): 
      #time complexity = nlog(log(n))
      prime = [True for i in range(n+1)]
      p = 2
      while (p * p <= n):
          if (prime[p] == True):
              for i in range(p * p, n+1, p):
                  prime[i] = False
          p += 1
      return prime
  def si():
      return input()
  def divideCeil(n,x):
      if (n%x==0):
          return n//x
      return n//x+1
  def ii():
      return int(input())
  def li():
      return list(map(int,input().split()))
  
  
  # ///////////////////////////////////////////////////////////////////////////
  # //////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
  # ///////////////////////////////////////////////////////////////////////////
  # if(os.path.exists('input.txt')):
  #     sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w") 
  # else:
  sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  class DisjointSetUnion:
      def __init__(self, n):
          self.parent = list(range(n))
          self.size = [1] * n
          self.num_sets = n
  
      def find(self, a):
          acopy = a
          while a != self.parent[a]:
              a = self.parent[a]
          while acopy != a:
              self.parent[acopy], acopy = a, self.parent[acopy]
          return a
  
      def union(self, a, b):
          a, b = self.find(a), self.find(b)
          if a != b:
              if self.size[a] < self.size[b]:
                  a, b = b, a
  
              self.num_sets -= 1
              self.parent[b] = a
              self.size[a] += self.size[b]
  
      def set_size(self, a):
          return self.size[self.find(a)]
  
      def __len__(self):
          return self.num_sets
  
  
  class UnionFind:
      def __init__(self, n):
          self.parent = list(range(n))
  
      def find(self, a):
          acopy = a
          while a != self.parent[a]:
              a = self.parent[a]
          while acopy != a:
              self.parent[acopy], acopy = a, self.parent[acopy]
          return a
  
      def union(self, a, b):
          self.parent[self.find(b)] = self.find(a)
  n,m1,m2 = li()
  adj1=  [[] for i in range(n)]
  adj2=  [[] for i in range(n)]
  dsu1 = DisjointSetUnion(n)
  dsu2 = DisjointSetUnion(n)
  for i in range(m1):
      a,b = li()
      a-=1
      b-=1
      adj1[a].append(b)
      adj1[b].append(a)
      dsu1.union(a,b)
  
  
  for i in range(m2):
      a,b = li()
      a-=1
      b-=1
      adj2[a].append(b)
      adj2[b].append(a)
      dsu2.union(a,b)
  
  
  ans = []
  for i in range(n):
      for j in range(i+1,n):
          p1 = dsu1.find(i)
          p2 = dsu1.find(j)
          # if i==1 and j==3:
          #     print("f",p1,p2)
          if p1==p2:
              continue
  
          p1 = dsu2.find(i)
          p2 = dsu2.find(j)
          if p1==p2:
              continue
  
          ans.append([i+1,j+1])
          dsu1.union(i,j)
          dsu2.union(i,j)
  print(len(ans))
  for i in ans:
      print(*i)
          
  