Rooks Game

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Rooks Game is a single-player game and uses a chessboard which has N×NN \times N grid and MM rook pieces.

A rook moves through any number of unoccupied squares horizontally or vertically. When a rook can attack another rook, it can capture the rook and move to the square which was occupied. Note that, in Rooks Game, we don't distinguish between white and black, in other words, every rook can capture any of other rooks.

Initially, there are MM rooks on the board. In each move, a rook captures another rook. The player repeats captures until any rook cannot be captured. There are two types of goal of this game. One is to minimize the number of captured rooks, and the other is to maximize it.

In this problem, you are requested to calculate the minimum and maximum values of the number of captured rooks.

입력

The first line contains two integers NN and MM which are the size of the chessboard and the number of rooks, respectively (1N,M10001 \le N,M \le 1000). Each of the following MM lines gives the position of each rook. The ii-th line with x_ix\_i and y_iy\_i means that the ii-th rook is in the x_ix\_i-th column and y_iy\_i-th row (1x_i,y_iN1 \le x\_i,y\_i \le N). You can assume any two rooks are not in the same place.

출력

Output the minimum and maximum values of the number of captured rooks separated by a single space.