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

Difficulty: MEDIUM_HARD
Tags: Sorting
Skill types: Sorting

Starter code:

Solutions:
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=10 ** 10, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
(n, m) = list(map(int, input().split()))
f = []
maxx = [-999999999] * n
minx = [999999999] * n
maxy = [-999999999] * n
miny = [999999999] * n
maxm = [-999999999] * (2 * n - 1)
minm = [999999999] * (2 * n - 1)
maxs = [-999999999] * (2 * n - 1)
mins = [999999999] * (2 * n - 1)
r = [0 for i in range(9)]
for i in range(m):
	(y, x) = list(map(int, input().split()))
	(a, b, c, d) = (y - 1, x - 1, y + x - 2, y - x + n - 1)
	f.append((a, b, c, d))
	if a > maxx[b]:
		maxx[b] = a
	if a < minx[b]:
		minx[b] = a
	if x - 1 > maxy[a]:
		maxy[a] = x - 1
	if x - 1 < miny[a]:
		miny[a] = x - 1
	if c > maxs[d]:
		maxs[d] = c
	if c < mins[d]:
		mins[d] = c
	if d > maxm[c]:
		maxm[c] = d
	if d < minm[c]:
		minm[c] = d
for i in f:
	k = 0
	if i[0] < maxx[i[1]]:
		k += 1
	if i[0] > minx[i[1]]:
		k += 1
	if i[1] < maxy[i[0]]:
		k += 1
	if i[1] > miny[i[0]]:
		k += 1
	if i[2] < maxs[i[3]]:
		k += 1
	if i[2] > mins[i[3]]:
		k += 1
	if i[3] < maxm[i[2]]:
		k += 1
	if i[3] > minm[i[2]]:
		k += 1
	r[k] += 1
print(*r)


def main():
	(n, m) = map(int, input().split())
	l = list((tuple(map(int, input().split())) for _ in range(m)))
	h = [False] * (n + 1)
	v = [False] * (n + 1)
	d1 = [False] * (n * 2 + 1)
	d2 = [False] * (n * 2 + 1)
	for (x, y) in l:
		line = h[y]
		if line:
			(mi, ma) = line
			if mi > x:
				h[y] = (x, ma)
			elif ma < x:
				h[y] = (mi, x)
		else:
			h[y] = (x, x)
		line = v[x]
		if line:
			(mi, ma) = line
			if mi > y:
				v[x] = (y, ma)
			elif ma < y:
				v[x] = (mi, y)
		else:
			v[x] = (y, y)
		xy = x + y
		line = d1[xy]
		if line:
			(mi, ma) = line
			if mi > x:
				d1[xy] = (x, ma)
			elif ma < x:
				d1[xy] = (mi, x)
		else:
			d1[xy] = (x, x)
		xy = x - y + n
		line = d2[xy]
		if line:
			(mi, ma) = line
			if mi > x:
				d2[xy] = (x, ma)
			elif ma < x:
				d2[xy] = (mi, x)
		else:
			d2[xy] = (x, x)
	res = [0] * 9
	for (x, y) in l:
		tot = 0
		(mi, ma) = v[x]
		if mi < y:
			tot += 1
		if y < ma:
			tot += 1
		for (mi, ma) in (h[y], d1[x + y], d2[x - y + n]):
			if mi < x:
				tot += 1
			if x < ma:
				tot += 1
		res[tot] += 1
	print(*res)
main()


(n, m) = map(int, input().split())
k = 2 * n + 1
t = [[0] * k for i in range(8)]
(p, r) = ([0] * m, [0] * 9)
for k in range(m):
	(x, y) = map(int, input().split())
	(a, b) = (n + y - x, y + x)
	p[k] = (x, y)
	if t[0][x]:
		(t[0][x], t[4][x]) = (min(t[0][x], y), max(t[4][x], y))
	else:
		t[0][x] = t[4][x] = y
	if t[1][y]:
		(t[1][y], t[5][y]) = (min(t[1][y], x), max(t[5][y], x))
	else:
		t[1][y] = t[5][y] = x
	if t[2][a]:
		(t[2][a], t[6][a]) = (min(t[2][a], x), max(t[6][a], x))
	else:
		t[2][a] = t[6][a] = x
	if t[3][b]:
		(t[3][b], t[7][b]) = (min(t[3][b], x), max(t[7][b], x))
	else:
		t[3][b] = t[7][b] = x
for (x, y) in p:
	(a, b) = (n + y - x, y + x)
	s = (t[0][x] == y) + (t[4][x] == y) + (t[1][y] == x) + (t[5][y] == x) + (t[2][a] == x) + (t[6][a] == x) + (t[3][b] == x) + (t[7][b] == x)
	r[8 - s] += 1
print(' '.join(map(str, r)))


(n, m) = list(map(int, input().split()))
f = []
maxx = [-999999999] * n
minx = [999999999] * n
maxy = [-999999999] * n
miny = [999999999] * n
maxm = [-999999999] * (2 * n - 1)
minm = [999999999] * (2 * n - 1)
maxs = [-999999999] * (2 * n - 1)
mins = [999999999] * (2 * n - 1)
r = [0 for i in range(9)]
for i in range(m):
	(y, x) = list(map(int, input().split()))
	(a, b, c, d) = (y - 1, x - 1, y + x - 2, y - x + n - 1)
	f.append((a, b, c, d))
	if a > maxx[b]:
		maxx[b] = a
	if a < minx[b]:
		minx[b] = a
	if x - 1 > maxy[a]:
		maxy[a] = x - 1
	if x - 1 < miny[a]:
		miny[a] = x - 1
	if c > maxs[d]:
		maxs[d] = c
	if c < mins[d]:
		mins[d] = c
	if d > maxm[c]:
		maxm[c] = d
	if d < minm[c]:
		minm[c] = d
for i in f:
	k = 0
	if i[0] < maxx[i[1]]:
		k += 1
	if i[0] > minx[i[1]]:
		k += 1
	if i[1] < maxy[i[0]]:
		k += 1
	if i[1] > miny[i[0]]:
		k += 1
	if i[2] < maxs[i[3]]:
		k += 1
	if i[2] > mins[i[3]]:
		k += 1
	if i[3] < maxm[i[2]]:
		k += 1
	if i[3] > minm[i[2]]:
		k += 1
	r[k] += 1
print(*r)