Problem: Problem

A dolphin who lives in a certain aquarium will be rewarded if he jumps and goes through the $ N $ ring.

* Dolphin jumps from coordinates $ (0,0) $ and lands at $ (T,0) $.
* The trajectory of the jump is a parabola.
* The $ i $ th ring is determined to have passed through when the jump trajectory intersects the line segment connecting $ (X_i, L_i) $ and $ (X_i, H_i) $.
* $ 1 $ jump requires as much physical strength as the initial velocity.



Dolphins can jump as many times as they want. Let the gravitational acceleration vector be $ (0, -1) $ and find the minimum total physical strength required for the dolphin to pass through all the rings. However, suppose friction and air resistance are negligibly small.

Constraints

The input satisfies the following conditions.

* All inputs are integers.
* $ 1 \ le X_i <T \ le 10 ^ 6 $
* $ 1 \ le N \ le 10 ^ 5 $
* $ 1 \ le L_i <H_i \ le 10 ^ 6 $

Input

The input is given in the following format.


$ T $ $ N $
$ X_1 $ $ L_1 $ $ H_1 $
$ \ vdots $
$ X_N $ $ L_N $ $ H_N $


First, $ T $ and $ N $ are given to the $ 1 $ line. Then the $ N $ line is given the position of the $ i $ th ring, $ X_i $, $ L_i $, and $ H_i $.

Output

Output the answer on one line. If the absolute error or relative error is $ 10 ^ {-9} $ or less, the answer is judged to be correct.

Examples

Input

100 5
50 1 5
50 5 10
50 20 30
50 40 60
50 61 1000000


Output

48.6090201099


Input

64 15
38 133177 927361
48 177920 668766
12 680425 790550
43 6853 384115
17 214954 723798
62 63843 153825
28 399349 482937
2 336136 367001
33 138008 733496
6 203462 911631
58 321974 527734
17 696940 781678
55 265874 507640
41 56037 880001
34 279422 528651


Output

6087.909851326286

Solution (in CPP):

Solution:
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
#define double long double
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-20, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(16) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

using PD = pair<double, double>;

ll T;

double get_v0(double y) {
  double W = T/2., H = y;
  double vx = W / sqrt(2 * H);
  double vy = sqrt(2 * H);
  return sqrt(vx * vx + vy * vy);
}

double f(double x, double y) {
  double a = x, b = y, W = T/2.;
  return b * W * W / (2 * a * W - a * a);
}

PD solve1(vector<PD> v) {
  each(p, v) swap(p.first, p.second);
  sort(all(v));
  double res = 0;
  double r = -linf;
  ll cnt = 0;
  each(p, v) {
    if (r >= p.second-eps) continue;
    r = p.first;
    res += get_v0(p.first);
    ++cnt;
  }
  // cout << cnt << endl;
  return PD(res, r);
}
PD solve2(vector<PD> v) {
  sort(all(v), greater<PD>());
  double res = 0;
  double l = linf;
  ll cnt = 0;
  each(p, v) {
    if (l <= p.second-eps) continue;
    l = p.first;
    res += get_v0(p.first);
    ++cnt;
  }
  // cout << cnt << endl;
  return PD(res, l);
}

void solve() {
  ll n; cin >> T >> n;
  vector<ll> X(n), L(n), H(n);
  rep(i, n) cin >> X[i] >> L[i] >> H[i];
  vector<PD> left, right, middle;
  double v = sqrt(T/2.);
  double tmid = T / v;
  double th = T / 4.;
  rep(i, n) {
    double l = f(X[i], L[i]);
    double r = f(X[i], H[i]);
    if (r <= th+eps) {
      left.eb(l, r);
    }
    else if (l >= th-eps) {
      right.eb(l, r);
    }
    else {
      middle.eb(l, r);
    }
    // cout << X[i] << " " << L[i] << " " << l << " " << r << endl;
  }
  // cout << left.size() << " " << right.size() << endl;
  auto r1 = solve1(left);
  auto r2 = solve2(right);
  // cout << r1.first << " " << get_v0(0.1973955598) << endl;
  double ans = r1.first + r2.first;
  double l = r1.second;
  double r = r2.second;
  bool flag = false;
  each(p, middle) {
    if (l+eps < p.first && p.second < r-eps) {
      flag = true;
      break;
    }
  }
  // 45度とばす
  if (flag) {
    ans += get_v0(th);
  }
  cout << ans << endl;
}