output_description: If S is hard to enter, print `Bad`; otherwise, print `Good`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: n = int(input())
  xy = [0] * n
  for i in range(n):
      xy[i] = tuple([int(j) for j in input().split()])
  loop = True
  cnt = 0
  while loop:
      xy_num = len(xy)
      for i in xy:
          a, b = i
          for j in xy:
              if j[0] == a and j[1] != b:
                  d = j[1]
                  for k in xy:
                      if k[1] == b and k[0] != a:
                          c = k[0]
                          if (c, d) not in xy:
                              xy.append((c, d))
                              cnt += 1
                      if k[1] == d and k[0] != a:
                          c = k[0]
                          if (c, b) not in xy:
                              xy.append((c, b))
                              cnt += 1
              if j[1] == b:
                  c = j[0]
                  for k in xy:
                      if k[0] == c and k[1] != b:
                          d = k[1]
                          if (a, d) not in xy:
                              xy.append((a, d))
                              cnt += 1
      if len(xy) == xy_num:
          loop = False
  print(cnt)
  
problem_description: Statement
  
  The door of Snuke's laboratory is locked with a security code.
  
  The security code is a 4-digit number. We say the security code is _hard to
  enter_ when it contains two consecutive digits that are the same.
  
  You are given the current security code S. If S is hard to enter, print `Bad`;
  otherwise, print `Good`.
samples: [{"input": "3776", "output": "Bad\n    \n\nThe second and third digits are the same, so 3776 is hard to enter.\n\n* * *"}, {"input": "8080", "output": "Good\n    \n\nThere are no two consecutive digits that are the same, so 8080 is not hard to\nenter.\n\n* * *"}, {"input": "1333", "output": "Bad\n    \n\n* * *"}, {"input": "0024", "output": "Bad"}]