Vasya has the square chessboard of size n x n and m rooks. Initially the chessboard is empty. Vasya would consequently put the rooks on the board one after another.
The cell of the field is under Rook ' s attack, if there are at least one rook located in the same row or in the same column With the 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 would put rooks. For each rook you has to determine the number of cells which is notunder attack after Vasya puts it on the board.
Input
The first line of the input contains the Integers n and m (1≤ n ≤100 000, 1≤ m ≤ min ($, n 2)) -the size of the board and the number of rooks .
Each of the next m lines contains integers xi and yi ( 1≤ x i, yi ≤ n)-the number of the row and the number of the column where Vasya would put the i-th rook. Vasya puts rooks on the board in the order they appear in the input. It is guaranteed the any cell would contain no more than one rook.
Output
Print m Integer, the i-th of them should is equal to the number of cells that is not under Atta CK after first i rooks is put.
Examplesinput
3 3
1 1
3 1
2 2
Output
Input
5 2
1 5
5 1
Output
Input
100000 1
300 400
Output
#include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> #include < string> #include <math.h> #include <cmath> #include <vector> #include <set>using namespace Std;int Main () {long long int n; long long int m; int a b; Cin >> n >> m; set <long long int> hang; set <long long int> lie;//Note here a long long int otherwise the first set of data can not be a long long int total = N*n; Long long int new_hang; Long long int new_lie; for (int i = 0; i < m; i++) {scanf ("%d%d", &a,&b); Hang.insert (a); Lie.insert (b); New_hang = N-hang.size (); NE W_lie = N-lie.size (); Total = New_hang * New_lie; cout << Total << "";}}
Crossfire 346# B