#include <bits/stdc++.h>
int res[100000];
int lf[4][2 * 100000 - 1][2];
int rt[4][2 * 100000 - 1][2];
int mres[9];
int n;
int m;
void add(int c, int n, int a, int x) {
  int us = 0;
  if (x < lf[c][n][1]) {
    if (lf[c][n][0] != -1) {
      res[lf[c][n][0]]++;
      res[a]++;
    }
    lf[c][n][0] = a;
    lf[c][n][1] = x;
    us = 1;
  }
  if (x > rt[c][n][1]) {
    if (rt[c][n][0] != -1) {
      res[rt[c][n][0]]++;
      res[a]++;
    }
    rt[c][n][0] = a;
    rt[c][n][1] = x;
    us = 1;
  }
  if (us == 0) res[a] = res[a] + 2;
}
int hn(int x, int y) { return y - 1; }
int hx(int x, int y) { return x - 1; }
int vn(int x, int y) { return x - 1; }
int vx(int x, int y) { return y - 1; }
int d1n(int x, int y) { return x + y - 2; }
int d1x(int x, int y) { return x - 1; }
int d2n(int x, int y) { return y - x + n - 1; }
int d2x(int x, int y) { return x - 1; }
int main() {
  scanf("%d%d", &n, &m);
  int i, j, x, y;
  for (i = 0; i < m; i++) res[i] = 0;
  for (j = 0; j < 2; j++) {
    for (i = 0; i < n; i++) lf[j][i][1] = n + 1;
    for (i = 0; i < n; i++) lf[j][i][0] = -1;
    for (i = 0; i < n; i++) rt[j][i][1] = -1;
    for (i = 0; i < n; i++) rt[j][i][0] = -1;
  }
  for (j = 2; j < 4; j++) {
    for (i = 0; i < (n * 2 - 1); i++) lf[j][i][1] = n + 1;
    for (i = 0; i < (n * 2 - 1); i++) lf[j][i][0] = -1;
    for (i = 0; i < (n * 2 - 1); i++) rt[j][i][1] = -1;
    for (i = 0; i < (n * 2 - 1); i++) rt[j][i][0] = -1;
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    add(0, hn(x, y), i, hx(x, y));
    add(1, vn(x, y), i, vx(x, y));
    add(2, d1n(x, y), i, d1x(x, y));
    add(3, d2n(x, y), i, d2x(x, y));
  }
  for (i = 0; i < 9; i++) mres[i] = 0;
  for (i = 0; i < m; i++) mres[res[i]]++;
  for (i = 0; i < 9; i++) printf("%d ", mres[i]);
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

A queen is the strongest chess piece. In modern chess the queen can move any number of squares in any horizontal, vertical or diagonal direction (considering that there're no other pieces on its way). The queen combines the options given to the rook and the bishop.

There are m queens on a square n × n chessboard. You know each queen's positions, the i-th queen is positioned in the square (ri, ci), where ri is the board row number (numbered from the top to the bottom from 1 to n), and ci is the board's column number (numbered from the left to the right from 1 to n). No two queens share the same position.

For each queen one can count w — the number of other queens that the given queen threatens (attacks). For a fixed attack direction only the first queen in this direction is under attack if there are many queens are on the ray of the attack. Obviously, for any queen w is between 0 and 8, inclusive.

Print the sequence t0, t1, ..., t8, where ti is the number of queens that threaten exactly i other queens, i.e. the number of queens that their w equals i.

Input

The first line of the input contains a pair of integers n, m (1 ≤ n, m ≤ 105), where n is the size of the board and m is the number of queens on the board. Then m following lines contain positions of the queens, one per line. Each line contains a pair of integers ri, ci (1 ≤ ri, ci ≤ n) — the queen's position. No two queens stand on the same square.

Output

Print the required sequence t0, t1, ..., t8, separating the numbers with spaces.

Examples

Input

8 4
4 3
4 8
6 5
1 6


Output

0 3 0 1 0 0 0 0 0 

Input

10 3
1 1
1 2
1 3


Output

0 2 1 0 0 0 0 0 0 

### Response

```cpp
#include <bits/stdc++.h>
int res[100000];
int lf[4][2 * 100000 - 1][2];
int rt[4][2 * 100000 - 1][2];
int mres[9];
int n;
int m;
void add(int c, int n, int a, int x) {
  int us = 0;
  if (x < lf[c][n][1]) {
    if (lf[c][n][0] != -1) {
      res[lf[c][n][0]]++;
      res[a]++;
    }
    lf[c][n][0] = a;
    lf[c][n][1] = x;
    us = 1;
  }
  if (x > rt[c][n][1]) {
    if (rt[c][n][0] != -1) {
      res[rt[c][n][0]]++;
      res[a]++;
    }
    rt[c][n][0] = a;
    rt[c][n][1] = x;
    us = 1;
  }
  if (us == 0) res[a] = res[a] + 2;
}
int hn(int x, int y) { return y - 1; }
int hx(int x, int y) { return x - 1; }
int vn(int x, int y) { return x - 1; }
int vx(int x, int y) { return y - 1; }
int d1n(int x, int y) { return x + y - 2; }
int d1x(int x, int y) { return x - 1; }
int d2n(int x, int y) { return y - x + n - 1; }
int d2x(int x, int y) { return x - 1; }
int main() {
  scanf("%d%d", &n, &m);
  int i, j, x, y;
  for (i = 0; i < m; i++) res[i] = 0;
  for (j = 0; j < 2; j++) {
    for (i = 0; i < n; i++) lf[j][i][1] = n + 1;
    for (i = 0; i < n; i++) lf[j][i][0] = -1;
    for (i = 0; i < n; i++) rt[j][i][1] = -1;
    for (i = 0; i < n; i++) rt[j][i][0] = -1;
  }
  for (j = 2; j < 4; j++) {
    for (i = 0; i < (n * 2 - 1); i++) lf[j][i][1] = n + 1;
    for (i = 0; i < (n * 2 - 1); i++) lf[j][i][0] = -1;
    for (i = 0; i < (n * 2 - 1); i++) rt[j][i][1] = -1;
    for (i = 0; i < (n * 2 - 1); i++) rt[j][i][0] = -1;
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    add(0, hn(x, y), i, hx(x, y));
    add(1, vn(x, y), i, vx(x, y));
    add(2, d1n(x, y), i, d1x(x, y));
    add(3, d2n(x, y), i, d2x(x, y));
  }
  for (i = 0; i < 9; i++) mres[i] = 0;
  for (i = 0; i < m; i++) mres[res[i]]++;
  for (i = 0; i < 9; i++) printf("%d ", mres[i]);
  return 0;
}

```