# Circle and Points

########################################
# 誤差
#
EPS = 1e-10

########################################
# case文でメソッドオーバーロードもどきを無理やり作るための比較演算子
#
class Class
  def ===(other)
    self==other
  end
end

########################################
#                  点
#
class Point
  include Comparable
  attr_accessor :x, :y
  def initialize(x=0.0, y=0.0)
    @x, @y = x.to_f, y.to_f
  end

  def <=>(p)
    @x != p.x ? @x <=> p.x : @y <=> p.y
  end
  def +(p)
    Point.new(@x+p.x, @y+p.y)
  end
  def -(p)
    Point.new(@x-p.x, @y-p.y)
  end
  def -@
    Point.new(-@x, -@y)
  end

  def times(f)
    Point.new(@x*f, @y*f)
  end
  def dot(p)
    @x*p.x + @y*p.y
  end
  def cross(p)
    @x*p.y - @y*p.x
  end
  def abs
    Math::hypot(@x, @y)
  end
  def norm
    @x**2 + @y**2
  end
  # 直線abと点pの位置関係を調べる
  # 0: 線分上, -1: 時計回り, 1: 反時計回り, -2: a-b-p, 2: p-a-b
  def ccw(b, p)
    a = self
    v1, v2 = b-a, p-a
    return 1 if v1.cross(v2) > 0
    return -1 if v1.cross(v2) < 0
    return 2 if v1.dot(v2) < 0
    return -2 if v1.norm < v2.norm
    0
  end
end

########################################
#                 直線
#
class Line
  attr_accessor :a, :b
  def initialize(p1=Point.new, p2=Point.new)
    @a, @b = p1, p2
  end

  # 直線abと点pの位置関係を調べる
  # 0: 線分上, -1: 時計回り, 1: 反時計回り, -2: a-b-p, 2: p-a-b
  def ccw(p)
    v1, v2 = @b - @a, p - @a
    return 1 if v1.cross(v2) > 0
    return -1 if v1.cross(v2) < 0
    return 2 if v1.dot(v2) < 0
    return -2 if v1.norm < v2.norm
    0
  end
  # 交差判定
  def intersect?(target)
    case target.class
      when Point
        v1, v2 = @a-target, @b-target
        return (v2.cross(v1)).abs == 0.0
      when Segment
        v1, v2, v3 = @b-@a, target.a-@a, target.b-@a
        return v1.cross(v2) * v1.cross(v3) <= 0.0
      when Line
        v1, v2, v3 = @b-@a, target.b-target.a, target.a-@a
        return v1.cross(v2).abs > 0.0 || v1.cross(v3).abs == 0.0
    end
  end
  # 直線上に射影した点
  def projection(p)
    v1, v2 = p-a, a-b
    a + v2.times(v1.dot(v2)/v2.norm)
  end
  # 直線に関して対象な点
  def reflection(p)
    p + (projection(p) - p).times(2.0)
  end
  # 距離
  def distance(target)
    case target.class
      when Point
        return (target - projection(target)).abs
      when Segment
        return intersect?(target) ? 0.0 : [distance(target.a), distance(target.b)].min
      when Line
        return intersect?(target) ? 0.0 : distance(target.a)
    end
  end
  # 交点
  def crosspoint(l)
    v1, v2, v3 = @b-@a, l.b-l.a, @b-l.a
    a, b = v1.cross(v2), v1.cross(v3)
    return l.a if a.abs == 0.0 && b.abs == 0.0
    l.a + v2.times(b/a)
  end
end

########################################
#                 線分
#
class Segment < Line
  # 交差判定
  def intersect?(target)
    case target.class
      when Point
        return (@a-target).abs + (@b-target).abs == (@b-@a).abs
      when Segment
        return target.ccw(@a) * target.ccw(@b) <= 0 && ccw(target.a) * ccw(target.b) <= 0
      when Line
        return target.intersect?(self)
    end
  end
  # 距離
  def distance(target)
    case target.class
      when Point
        p = projection(target)
        return intersect?(p) ? (p-target).abs : [(@a-target).abs, (@b-target).abs].min
      when Segment
        return intersect?(target) ? 0.0 : [distance(target.a), distance(target.b), target.distance(@a), target.distance(@b)].min
      when Line
        return target.distance(self)
    end
  end
end

########################################
#                  円
#
class Circle
  include Comparable
  attr_accessor :x, :y, :r
  def initialize(x=0.0, y=0.0, r=1.0)
    @x, @y, @r = x.to_f, y.to_f, r.to_f
  end

  def <=>(c)
    @x!=c.x ? @x<=>c.x : (@y!=c.y ? @y<=>c.y : @r<=>c.r)
  end

  def point
    Point.new(@x, @y)
  end
  def distance(c)
    (point-c.point).abs
  end
  # 点を含むか
  def include?(p)
#     (point-p).abs <= @r         # 誤差死 AOJ1190
    (point-p).abs - @r <= EPS
  end
  # 円に含まれるか
  def in?(c)
#     distance(c) < (@r-c.r).abs  # 誤差死 AOJ1190
    distance(c) - (@r-c.r).abs < EPS
  end
  # 交差判定
  def touch?(c)
    distance(c) <= @r + c.r     # 誤差死の可能性？
#     distance(c) - @r - c.r <= EPS
  end
  # 交点
  def crosspoint(c)
    angle = Math::atan2(c.y-@y, c.x-@x)
    d = distance(c)
    add = Math::acos((d**2 + @r**2 - c.r**2) / (2.0*d*@r))
    p1 = Point.new(@x+@r*Math::cos(angle+add), @y+@r*Math::sin(angle+add))
    p2 = Point.new(@x+@r*Math::cos(angle-add), @y+@r*Math::sin(angle-add))
    [p1, p2]
  end
end

########################################
# メイン
while (n = gets.to_i) != 0
  point = Array.new
  circle = Array.new
  n.times do
    x, y, r = *gets.split.map(&:to_f), 1.0
    point.push(Point.new(x, y))
    circle.push(Circle.new(x, y, r))
  end
  crosspoint = Array.new
  for i in 0...(n-1) do
    for j in (i+1)...n do
      next unless circle[i].touch?(circle[j])
      crosspoint.push(*circle[i].crosspoint(circle[j]))
    end
  end
  answer = 0
  crosspoint.each do |cp|
    count = 0
    point.each do |p|
      count += 1 if Circle.new(cp.x, cp.y, 1.0).include?(p)
    end
    answer = [answer, count].max
  end
  p answer
end