Problem: Due to atheistic Soviet past, Christmas wasn't officially celebrated in Russia for most of the twentieth century. As a result, the Russian traditions for Christmas and New Year mixed into one event celebrated on the New Year but including the tree, a Santa-like 'Grandfather Frost', presents and huge family reunions and dinner parties all over the country. Bying a Tree at the New Year and installing it in the house is a tradition. Usually the whole family decorates the tree on the New Year Eve. We hope that Codeforces is a big and loving family, so in this problem we are going to decorate a tree as well.

So, our decoration consists of n pieces, each piece is a piece of colored paper, its border is a closed polyline of a special shape. The pieces go one by one as is shown on the picture. The i-th piece is a polyline that goes through points: (0, 0), (0, y0), (1, y1), (2, y2), ..., (k, yk), (k, 0). The width of each piece equals k.

<image> The figure to the left shows the decoration, the figure to the right shows the individual pieces it consists of.

The piece number 1 (shown red on the figure) is the outer piece (we see it completely), piece number 2 (shown yellow) follows it (we don't see it completely as it is partially closed by the first piece) and so on. The programmers are quite curious guys, so the moment we hung a decoration on the New Year tree we started to wonder: what area of each piece can people see?

Input

The first line contains two integers, n and k (1 ≤ n, k ≤ 300). Each of the following n lines contains k + 1 integers — the description of the polyline. If the i-th line contains ontegers yi, 0, yi, 1, ..., yi, k, that means that the polyline of the i-th piece goes through points (0, 0), (0, yi, 0), (1, yi, 1), (2, yi, 2), ..., (k, yi, k), (k, 0) (1 ≤ yi, j ≤ 1000).

Output

Print n real numbers — for each polyline, the area of its visible part.

The answer will be considered correct if its relative or absolute error do not exceed 10 - 4. 

Examples

Input

2 2
2 1 2
1 2 1


Output

3.000000000000
0.500000000000


Input

1 1
1 1


Output

1.000000000000


Input

4 1
2 7
7 2
5 5
6 4


Output

4.500000000000
1.250000000000
0.050000000000
0.016666666667

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 333;
const double EPS = 1.0e-8;
int n, k;
double a[MAX_N][MAX_N];
inline int sgn(double x) { return (x > EPS) - (x < -EPS); }
struct Point {
  double x, y;
  Point() : x(0.0), y(0.0) {}
  Point(double x, double y) : x(x), y(y) {}
  bool operator==(const Point& o) const {
    return sgn(x - o.x) == 0 && sgn(y - o.y) == 0;
  }
};
struct Line {
  double a, b;
  Line() : a(0.0), b(0.0) {}
  Line(double a, double b) : a(a), b(b) {}
} l[MAX_N][MAX_N];
int cnt[MAX_N], m;
double w[MAX_N][MAX_N];
inline double gao(Line& l1, Line& l2) { return (l2.b - l1.b) / (l1.a - l2.a); }
inline double getY(Line& l1, double x) { return x * l1.a + l1.b; }
inline int isAt(Point& p1, Line& l1) { return sgn(p1.y - getY(l1, p1.x)); }
inline double xmult(Point a, Point b, Point o) {
  return (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
}
Line p[MAX_N];
double now[MAX_N];
Point pt[MAX_N], pt2[MAX_N];
Line getLine(Point& p1, Point& p2) {
  double k = (p2.y - p1.y) / (p2.x - p1.x);
  return Line(k, p1.y - p1.x * k);
}
double getArea(Point pt[], int pnum) {
  Point o = Point(0.0, 0.0);
  double res = 0.0;
  for (int i = 0; i < pnum; i++) {
    res += xmult(pt[i], pt[(i + 1) % pnum], o);
  }
  return fabs(res / 2.0);
}
int main() {
  while (scanf("%d%d", &n, &k) == 2) {
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= k; j++) {
        scanf("%lf", &a[i][j]);
      }
    }
    fill(l[0], l[k + 2], Line());
    fill(cnt, cnt + k + 2, 0);
    for (int i = 0; i < k; i++) {
      w[i][0] = i;
      w[i][++cnt[i]] = i + 1;
    }
    for (int i = 1; i <= n; i++) {
      double res = 0.0;
      for (int j = 0; j < k; j++) {
        double y1 = a[i][j];
        double y2 = a[i][j + 1];
        Line tp = Line(y2 - y1, y1 - (y2 - y1) * j);
        int m = 0;
        if (sgn(getY(tp, w[j][0]) - getY(l[j][0], w[j][0])) >= 0) {
          pt[m++] = Point((double)j, y1);
        }
        for (int o = 0; o < cnt[j]; o++) {
          if (sgn(getY(tp, w[j][o]) - getY(l[j][o], w[j][o])) <= 0) {
            pt[m++] = Point(w[j][o], getY(l[j][o], w[j][o]));
          }
          if (sgn(l[j][o].a - tp.a) == 0) {
            if (sgn(l[j][o].b - tp.b) == 0) {
              pt[m++] = Point(w[j][o], getY(l[j][o], w[j][o]));
            }
            continue;
          }
          double x = gao(l[j][o], tp);
          if (sgn(x - w[j][o]) >= 0 && sgn(w[j][o + 1] - x) >= 0) {
            pt[m++] = Point(x, getY(tp, x));
          }
        }
        if (sgn(getY(tp, j + 1.0) - getY(l[j][cnt[j] - 1], j + 1.0)) >= 0) {
          pt[m++] = Point(j + 1.0, y2);
        } else {
          pt[m++] = Point(j + 1.0, getY(l[j][cnt[j] - 1], j + 1.0));
        }
        m = unique(pt, pt + m) - pt;
        int pnum = 0;
        for (int o = 0; o < cnt[j]; o++) {
          if (sgn(getY(tp, w[j][o]) - getY(l[j][o], w[j][o])) > 0) {
            pt2[pnum++] = Point(w[j][o], getY(l[j][o], w[j][o]));
          }
        }
        if (sgn(getY(tp, w[j][cnt[j]]) - getY(l[j][cnt[j] - 1], w[j][cnt[j]])) >
            0) {
          pt2[pnum++] =
              Point(w[j][cnt[j]], getY(l[j][cnt[j] - 1], w[j][cnt[j]]));
        }
        for (int o = m - 1; o >= 0; o--) {
          if (isAt(pt[o], tp) == 0) {
            pt2[pnum++] = pt[o];
          }
        }
        res += getArea(pt2, pnum);
        cnt[j] = m - 1;
        for (int o = 0; o < m - 1; o++) {
          l[j][o] = getLine(pt[o], pt[o + 1]);
          w[j][o] = pt[o].x;
        }
        w[j][m - 1] = pt[m - 1].x;
      }
      printf("%.10lf\n", res);
    }
  }
  return 0;
}