#D11787. Rooks Game

    ID: 9802 Type: Default 2000ms 536MiB

Rooks Game

Rooks Game

Problem Statement

"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.


Input

The input consists of a single test case in the format below.

NN MM x1x_{1} y1y_{1} \vdots xMx_{M} yMy_{M}

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 xix_{i} and yiy_{i} means that the ii-th rook is in the xix_{i}-th column and yiy_{i}-th row (1xi,yiN1 \le x_{i}, y_{i} \le N). You can assume any two rooks are not in the same place.

Output

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

Examples

Input Output

8 3 1 1 1 8 8 8

|

1 2

8 4 1 1 1 8 8 8 8 1

|

2 3

5 5 1 1 2 2 3 3 4 4 5 5

|

0 0

100 1 100 100

|

0 0

10 12 1 2 1 4 1 6 3 6 5 6 10 7 8 7 6 7 4 7 2 7 7 3 9 5

|

7 8

Example

Input

Output

inputFormat

Input

The input consists of a single test case in the format below.

NN MM x1x_{1} y1y_{1} \vdots xMx_{M} yMy_{M}

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 xix_{i} and yiy_{i} means that the ii-th rook is in the xix_{i}-th column and yiy_{i}-th row (1xi,yiN1 \le x_{i}, y_{i} \le N). You can assume any two rooks are not in the same place.

outputFormat

Output

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

Examples

Input Output

8 3 1 1 1 8 8 8

|

1 2

8 4 1 1 1 8 8 8 8 1

|

2 3

5 5 1 1 2 2 3 3 4 4 5 5

|

0 0

100 1 100 100

|

0 0

10 12 1 2 1 4 1 6 3 6 5 6 10 7 8 7 6 7 4 7 2 7 7 3 9 5

|

7 8

Example

Input

Output

样例