National Olympiad in Informatics, China, 2008
The annual masquerade ball has begun, and DongDong will be enthusiastically participating. This year's masks are specially tailored by the host. Each person going to the party can choose a mask of their liking before they enter. Each mask is labeled with a number, and the host will tell this number to the person wearing the mask.
To give the party a more mystifying atmosphere, the host has divided the
masks into
Guests of the party will not know just how many types of masks there are in the party. However, this has made DongDong very curious, so he decided to calculate for himself how many types of masks there are. Thus, he starts collecting information from the crowd of people.
DongDong's information tells him which person wearing one mask
can see which other people's mask numbers. For example, person
number
Since not everybody can just remember all of the numbers they have seen,
DongDong's information is not guaranteed to be perfectly complete. Now
you must calculate, based on DongDong's current set of information, the
maximum possible and minimum possible number of types of masks there may be.
This is assuming there is at least one person at the party wearing
a mask of type
Input Specification
The first line of input contains two space-separated integers
In the following
Output Specification
Output two space-separated integers on one line. The first integer is
the maximum possible types of masks there may be, and the second integer
is the minimum possible types of masks there may be. If there is no way
to divide the masks into at least -1
twice.
Sample Input 1
6 5
1 2
2 3
3 4
4 1
3 5
Sample Output 1
4 4
Sample Input 2
3 3
1 2
2 1
2 3
Sample Output 2
-1 -1
Constraints
For
For
Problem translated to English by .
Comments