output_description: For each dataset, print a line containing an integer indicating the maximum
  number of discs that can be removed.
input_description: The input consists of multiple datasets, each being in the following format
  and representing the state of a game just after all the discs are scattered.
  
  > _n_  
  >  _x_ 1 _y_ 1 _r_ 1 _c_ 1  
  >  _x_ 2 _y_ 2 _r_ 2 _c_ 2  
  >  ...  
  >  _x_ _n_ _y_ _n_ _r_ _n_ _c_ _n_  
  >
  
  The first line consists of a positive integer _n_ representing the number of
  discs. The following _n_ lines, each containing 4 integers separated by a
  single space, represent the colors, sizes, and initial placings of the _n_
  discs in the following manner:
  
    * (_x_ _i_ , _y_ _i_), _r_ _i_ , and _c_ _i_ are the _xy_ -coordinates of the center, the radius, and the color index number, respectively, of the _i_ -th disc, and 
    * whenever the _i_ -th disc is put on top of the _j_ -th disc, _i_ < _j_ must be satisfied. 
  
  You may assume that every color index number is between 1 and 4, inclusive,
  and at most 6 discs in a dataset are of the same color. You may also assume
  that the _x_ \- and _y_ -coordinates of the center of every disc are between 0
  and 100, inclusive, and the radius between 1 and 100, inclusive.
  
  The end of the input is indicated by a single zero.
attempt: def xx(x):
      return x * x
  
  
  def pop(overlaps, i, lis):
      for k in lis:
          if i > k and overlaps[i][k]:
              return False
      return True
  
  
  def search(disks, overlaps, lis):
      if len(lis) < 2:
          return 0
      res = 0
      for i in lis:
          if not pop(overlaps, i, lis):
              continue
          # print("OK", i)
          for k in lis:
              if i == k:
                  continue
              if disks[i][3] != disks[k][3]:
                  continue
              if not pop(overlaps, k, lis):
                  continue
              # print("Good", k)
              giv = list(lis)
              giv.remove(i)
              giv.remove(k)
              res = max(res, 2 + search(disks, overlaps, giv))
      return res
  
  
  while True:
      n = int(input())
      if n == 0:
          break
      disks = [list(map(int, input().split(" "))) for _ in range(n)]
  
      overlaps = []
      for i in range(n):
          res = []
          for k in range(n):
              a = disks[i]
              b = disks[k]
              res.append(xx(a[0] - b[0]) + xx(a[1] - b[1]) < xx(a[2] + b[2]))
          overlaps.append(res)
      # print(overlaps)
  
      print(search(disks, overlaps, list(range(n))))
  
problem_description: _And Then, How Many Are There?_
  
  To Mr. Solitarius, who is a famous solo play game creator, a new idea occurs
  like every day. His new game requires discs of various colors and sizes.
  
  To start with, all the discs are randomly scattered around the center of a
  table. During the play, you can remove a pair of discs of the same color if
  neither of them has any discs on top of it. Note that a disc is not considered
  to be on top of another when they are externally tangent to each other.
  
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_1175)  
    
  Figure D-1: Seven discs on the table  
  
  For example, in Figure D-1, you can only remove the two black discs first and
  then their removal makes it possible to remove the two white ones. In
  contrast, gray ones never become removable.
  
  You are requested to write a computer program that, for given colors, sizes,
  and initial placings of discs, calculates the maximum number of discs that can
  be removed.
samples: [{"input": "0 0 50 1\n    0 0 50 2\n    100 0 50 1\n    0 0 100 2\n    7\n    12 40 8 1\n    10 40 10 2\n    30 40 10 2\n    10 10 10 1\n    20 10 9 3\n    30 10 8 3\n    40 10 7 3\n    2\n    0 0 100 1\n    100 32 5 1\n    0", "output": "4\n    0"}]