output_description: For each dataset, output a line containing the number indicating the time _t_
  of the last moment when the sunlight is blocked. The value should not have an
  error greater than 0.001. No extra characters should appear in the output.
input_description: The input consists of multiple datasets. The first line of a dataset contains
  two integers _r_ and _n_ separated by a space. _r_ is the radius of the sun
  and _n_ is the number of silhouettes of the buildings. (1 ≤ _r_ ≤ 20, 0 ≤ _n_
  ≤ 20)
  
  Each of following _n_ lines contains three integers _x li_, _x ri_, _h i_ (1 ≤
  _i_ ≤ _n_) separated by a space.
  
  These three integers represent a silhouette rectangle of a building. The
  silhouette rectangle is parallel to the horizon, and its left and right edges
  are at _x_ = _x li_ and _x_ = _x ri_, its top edge is at _y_ = _h i_, and its
  bottom edge is on the horizon. (-20 ≤ _x li_ < _x ri_ ≤ 20, 0 < _h i_ ≤ 20)
  
  The end of the input is indicated by a line containing two zeros separated by
  a space.
  
  Note that these silhouettes may overlap one another.
attempt: import sys
  
  EPS = 1e-9
  
  
  def normalize(x):
      return 2 * (x + 20)
  
  
  def check(seg, r, t):
  
      for x in range(40 - r, 40 + r + 1):
          ok = False
          for s in seg:
              if s[2] < t - r:
                  # print("over!!!! x:{}, s[2]:{}, t-r:{}",x,s[2],t-r)
                  return False
              if s[0] <= x and x <= s[1]:
                  k1 = (s[0] - 40) ** 2 + (s[2] - (t - r)) ** 2
                  k2 = (s[1] - 40) ** 2 + (s[2] - (t - r)) ** 2
                  # print("\tx:{}\ts[2]:{}\tt/2:{}\tr:{}\tk1:{}\tk2:{}\tkk:{}".format(x, s[2], t/2, r, k1, k2,kk))
                  if k1 >= r * r and k2 >= r * r:
                      ok = True
                      break
  
          if not ok:
              return False
  
      return True
  
  
  def main():
  
      while True:
          r, n = map(int, sys.stdin.readline().split())
          if r == 0 and n == 0:
              break
  
          seq = [0] * 100  # 2?????§?¨??????????
          for i in range(n):
              x1, x2, h = map(int, sys.stdin.readline().split())
              for x in range(normalize(x1), normalize(x2) + 1):
                  seq[x] = max(seq[x], 2 * h)
  
          prev = 0
          st = 0
          seg = []
          for i in range(100):
              if prev != seq[i]:
                  if i % 2 == 0:
                      seg.append([st, i, prev])
                      st = i
                  else:
                      seg.append([st, i - 1, prev])
                      st = i - 1
                  prev = seq[i]
  
          # ????????????????????¨?????????????????????????????????????????§?????????append?????????
          # ??????1??\?????????????????\???
          r *= 2
          seg = [x for x in seg if x[2] > 0 and (40 - r <= x[0] or x[1] <= 40 + r)]
  
          # ????????§?¨???????????????????????????????????????????????????????
          for i in range(len(seg) - 1):
              if seg[i][1] == seg[i + 1][0]:
                  if seg[i][2] > seg[i + 1][2]:
                      seg[i + 1][0] += EPS
                  elif seg[i][2] < seg[i + 1][2]:
                      seg[i][1] -= EPS
  
          # print(seg)
  
          tl = 0.0
          tr = 40.0
          for k in range(60):
              tm = (tr + tl) / 2.0
              if check(seg, r, tm):
                  tl = tm
              else:
                  tr = tm
  
          print("{0:.4f}".format(tl / 2))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Vampire
  
  Mr. C is a vampire. If he is exposed to the sunlight directly, he turns into
  ash. Nevertheless, last night, he attended to the meeting of Immortal and
  Corpse Programmers Circle, and he has to go home in the near dawn.
  Fortunately, there are many tall buildings around Mr. C's home, and while the
  sunlight is blocked by the buildings, he can move around safely. The top end
  of the sun has just reached the horizon now. In how many seconds does Mr. C
  have to go into his safe coffin?
  
  To simplify the problem, we represent the eastern dawn sky as a 2-dimensional
  _x_ -_y_ plane, where the _x_ axis is horizontal and the _y_ axis is vertical,
  and approximate building silhouettes by rectangles and the sun by a circle on
  this plane.
  
  The _x_ axis represents the horizon. We denote the time by _t_ , and the
  current time is _t_ =0. The radius of the sun is _r_ and its center is at (0,
  -_r_) when the time _t_ =0. The sun moves on the _x_ -_y_ plane in a uniform
  linear motion at a constant velocity of (0, 1) per second.
  
  The sunlight is blocked if and only if the entire region of the sun (including
  its edge) is included in the union of the silhouettes (including their edges)
  and the region below the horizon (y ≤ 0).
  
  Write a program that computes the time of the last moment when the sunlight is
  blocked.
  
  The following figure shows the layout of silhouettes and the position of the
  sun at the last moment when the sunlight is blocked, that corresponds to the
  first dataset of Sample Input below. As this figure indicates, there are
  possibilities that the last moment when the sunlight is blocked can be the
  time _t_ =0.
  
    
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_domestic2014_C_fig0)  
  
  The sunlight is blocked even when two silhouettes share parts of their edges.
  The following figure shows the layout of silhouettes and the position of the
  sun at the last moment when the sunlight is blocked, corresponding to the
  second dataset of Sample Input. In this dataset the radius of the sun is 2 and
  there are two silhouettes: the one with height 4 is in -2 ≤ _x_ ≤ 0, and the
  other with height 3 is in 0 ≤ _x_ ≤ 2\.
  
    
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_domestic2014_C_fig1)
samples: [{"input": "3\n    -2 -1 3\n    0 1 3\n    2 3 3\n    2 2\n    -2 0 4\n    0 2 3\n    2 6\n    -3 3 1\n    -2 3 2\n    -1 3 3\n    0 3 4\n    1 3 5\n    2 3 6\n    2 6\n    -3 3 1\n    -3 2 2\n    -3 1 3\n    -3 0 4\n    -3 -1 5\n    -3 -2 6\n    0 0", "output": ".0000\n    3.0000\n    2.2679\n    2.2679"}]