Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another.

The cell of the field is under rook's attack, if there is at least one rook located in the same row or in the same column with this cell. If there is a rook located in the cell, this cell is also under attack.

You are given the positions of the board where Vasya will put rooks. For each rook you have to determine the number of cells which are not under attack after Vasya puts it on the board.


-----Input-----

The first line of the input contains two integers n and m (1 ≤ n ≤ 100 000, 1 ≤ m ≤ min(100 000, n^2)) — the size of the board and the number of rooks. 

Each of the next m lines contains integers x_{i} and y_{i} (1 ≤ x_{i}, y_{i} ≤ n) — the number of the row and the number of the column where Vasya will put the i-th rook. Vasya puts rooks on the board in the order they appear in the input. It is guaranteed that any cell will contain no more than one rook.


-----Output-----

Print m integer, the i-th of them should be equal to the number of cells that are not under attack after first i rooks are put.


-----Examples-----
Input
3 3
1 1
3 1
2 2

Output
4 2 0 

Input
5 2
1 5
5 1

Output
16 9 

Input
100000 1
300 400

Output
9999800001 



-----Note-----

On the picture below show the state of the board after put each of the three rooks. The cells which painted with grey color is not under the attack.

 [Image]

Difficulty: interview

Starter code:

Solutions:
n, m = map(int, input().split())
sum = n ** 2
colx = n
coly = n
usedx = [False] * n
usedy = [False] * n
for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    if not usedx[x]:
        sum -= coly
        usedx[x] = True
        colx -= 1
    if not usedy[y]:
        sum -= colx
        usedy[y] = True
        coly -= 1
    print(sum, end = ' ')


n, m = list(map(int, input().split()))
row = set()
col = set()
s = ""
for i in range(m):
    r, c = list(map(int, input().split()))
    row.add(r)
    col.add(c)
    dead = len(row)*n+len(col)*(n-len(row))
    s += str(n*n - dead) + " "
print(s)


from collections import *
c,r=Counter(),Counter()
n,k=list(map(int,input().split()))
ans=[]
for i in range(k):
    i,j=list(map(int,input().split()))
    c[i],r[j]=1,1
    li,lj=len(c),len(r)
    ans.append(n*n-li*n-lj*n+li*lj)
print(*ans)


n, m = map(int,input().split())
xyi = [list(map(int,input().split())) for i in range(m)]
x = [0]*(n+1)
y = [0]*(n+1)
numx = 0
numy = 0
num = n*n
for i in range(m):
    if x[xyi[i][0]] == 0:
        num += numy - n
        numx += 1
        x[xyi[i][0]] = 1
    if y[xyi[i][1]] == 0:
        num += numx - n
        numy += 1
        y[xyi[i][1]] = 1
    print(num, end=" ")
    


n, m = map(int, input().split())

c = set()
r = set()

for i in range(m):
    x, y = map(int, input().split())
    c.add(x)
    r.add(y)

    c1 = len(c)
    r1 = len(r)
    #print(c1, r1)

    print((n * n) - (c1 * n + ((n - c1) * r1)), end=" ")

print("")
    



n, m = list(map(int, input().split()))

columns = set()
rows = set()

results = []
for _ in range(m):
    x, y = list(map(int, input().split()))

    columns.add(x)
    rows.add(y)

    result = n * (n - len(columns)) - (n - len(columns)) * len(rows)
    results.append(result)

print(' '.join(map(str, results)))


n,m=map(int,input().split())
xs=[0 for i in range(n)]
ys=[0 for i in range(n)]
l=0
k=0
for i in range(m):
    x,y=map(int,input().split())
    if xs[x-1]!=1:
        xs[x-1]=1
        l+=1
    if ys[y-1]!=1:
        ys[y-1]=1
        k+=1
    print(n*n-(l+k)*n+l*k,end=' ')


import sys

n, rooks = map(int, input().split())

rows = [False for _ in range(n+1)]
columns = [False for _ in range(n+1)]

empty_rows = n
empty_columns = n

for i in range(rooks):
	x, y = map(int, input().split())
	if not rows[x]:
		rows[x] = True
		empty_rows -= 1
	if not columns[y]:
		columns[y] = True
		empty_columns -= 1
	if i == rooks - 1:
		print(empty_rows * empty_columns)
	else:
		print(empty_rows * empty_columns, end=' ')



n, m = map(int, input().split())

free_verticals = set(range(1, n+1))
free_horizontals = set(range(1, n+1))


for _ in range(m):
    x, y = map(int, input().split())
    free_verticals.discard(x)
    free_horizontals.discard(y)
    print(len(free_horizontals) * len(free_verticals), end=' ')
print()


a,s=input().split()
a=int(a)
s=int(s)
top1=a
top2=a
l1=[]
l2=[]
l3=[]
for i in range(0,100007):
    l1.append(0)
    l2.append(0)
for i in range(0,s):
    z,x=input().split()
    z=int(z)
    x=int(x)
    if l1[z]==0:
        top1-=1
        l1[z]=1
    if l2[x]==0:
        top2-=1
        l2[x]=1
    l3.append(top1*top2)
for i in l3:
    print(i,end=" ")
    


n, m = map(int, input().split())
xvis = [False]*(n+1)
yvis = [False]*(n+1)
xc = 0
yc = 0

def cal():
    s = (n-xc)*n - (n-xc)*yc
    return s

for i in range(m):
    x, y = map(int, input().split())
    if not(xvis[x]):
        xvis[x] = True
        xc += 1
    if not(yvis[y]):
        yvis[y] = True
        yc += 1
    print(cal(), end = ' ')


n,m=[int(i) for i in input().strip().split()]
r_atk=set()
c_atk=set()
for __ in range(m):
  r,c=[int(i) for i in input().strip().split()]
  if r not in r_atk:
    r_atk.add(r)
  if c not in c_atk:
    c_atk.add(c)
  print((n-len(r_atk))*(n-len(c_atk)),end=' ')

n = input().split()
m = int(n[1])
n = int(n[0])
x = set()
y = set()
s = list()
e = 0
for i in range(0,m):
    t = input().split()
    x.add(int(t[0]))
    y.add(int(t[1]))
    num = (n-len(x))*(n-len(y))
    if num < 0:
        e = i
        break;
    s.append(str(num))
if e != 0:
    c = ["0" for l in range(e,m)]
    #for i in range(e, m):
    #    t = input()
    s.extend(c)
st=" "
print(st.join(s))

read = lambda: list(map(int, input().split()))
n, m = read()
ans = [0] * m
dx = [0] * (n + 1)
dy = [0] * (n + 1)
cur = n ** 2
kx = ky = 0
for i in range(m):
    x, y = read()
    if dx[x] == 0 and dy[y] == 0:
        cur = cur - n - n + kx + ky + 1
        kx += 1
        ky += 1
        dx[x] = 1
        dy[y] = 1
    elif dx[x] == 0 and dy[y] == 1:
        cur = cur - n + ky
        kx += 1
        dx[x] = 1
    elif dx[x] == 1 and dy[y] == 0:
        cur = cur - n + kx
        ky += 1
        dy[y] = 1
    ans[i] = cur
print(*ans)


A = input().split()
n=int(A[0])
m=int(A[1])
s=n**2
B = [0] * (n+1)
C = [0] * (n+1)
x1=n
y1=n
for i in range(m):
   A = input().split()
   x=int(A[0])
   y=int(A[1])
   if B[x]==0 and C[y]==0:
       s=s-x1-y1+1
       x1-=1
       y1-=1
   if B[x]==1 and C[y]==0:
       s=s-y1
       x1-=1
   if B[x]==0 and C[y]==1:
       s=s-x1
       y1-=1    
   B[x]=1
   C[y]=1
   print(s, end=' ')
   


n, m = [int(i) for i in input().split()]
s = [[0, 0] for i in range(n)]
r = n**2
ans = []
q = 0
w = 0
for i in range(m):
	a, b = [int(y) for y in input().split()]
	if not s[a-1][0]:
		q+=1
	if not s[b-1][1]:
		w+=1
	s[a-1][0]+=1
	s[b-1][1]+=1
	ans.append(n**2-q*n-w*n+q*w)
print(*ans)


n, m = list(map(int, input().strip().split()))

remains = n*n
deleted_rows = set()
deleted_cols = set()
answer = []
for _ in range(m):
    c, r = list(map(int, input().strip().split()))
    col_deleted = c in deleted_cols
    row_deleted = r in deleted_rows
    if not (col_deleted and row_deleted):
        if col_deleted:
            remains -= (n - len(deleted_cols))
        elif row_deleted:
            remains -= (n - len(deleted_rows))
        else:  # not x_in and not y_in
            remains -= (2*n - len(deleted_cols) - len(deleted_rows) - 1)

    deleted_cols.add(c)
    deleted_rows.add(r)

    answer.append(str(remains))

print(' '.join(answer))


def pro():
    n, m = map(int, input().split())
    x = [False for i in range(n)]
    x1 = n
    y = [False for i in range(n)]
    y1 = n
    for i in range(m):
        k,l = map(int, input().split())
        if not x[k - 1]:
            x[k - 1] = True
            x1 -= 1
        if not y[l - 1]:
            y[l - 1] = True
            y1 -= 1
        print(x1 * y1, end=' ')
pro()

N, M = map(int, input().split())

r = N
c = N

R = [False for i in range(N)]
C = R.copy()

for i in range(M):
    a, b = map(int, input().split())

    if not R[a-1]:
        r -= 1
        R[a-1] = True

    if not C[b-1]:
        c -= 1
        C[b-1] = True

    print(r*c, end=' ')