Sophie's Birthday Party

No attempts yetTime limit3sMemory limit128 MB

Problem

Little Sophie is throwing a birthday party and has written a tentative list of kindergarten friends she would like to invite. The kids, however, are demanding guests: some of them refuse to come if certain other kids are also invited. For example, Mary agrees to come only if neither Camille nor Emily is present, because they took her doll last week; little Christopher will only play with Sophie and Camille and does not want to see anyone else; and so on.

We describe these wishes as objections: an objection (a,b)(a, b) means that kid aa does not want to meet kid bb at the party. Sophie considers the party a success if no invited guest has an objection against any other invited guest. In other words, if kid aa objects to kid bb or kid bb objects to kid aa, then aa and bb cannot both be invited.

Sophie will leave out some kids to make sure the party succeeds, but she wants to invite as many kids as possible. If she cannot invite at least kk kids, she will not hold the party at all.

Given all the objections, determine the largest number of kids Sophie can invite so that the party is a success, or decide that inviting at least kk kids is impossible.

Input

The first line contains two integers nn and kk separated by a single space: nn is the number of Sophie's acquaintances and kk is the minimum number of kids she wants to invite, with 2n1062 \le n \le 10^6 and n10k<nn - 10 \le k < n. The kids are numbered from 11 to nn.

The second line contains a single integer mm, the number of objections, with 1m3×1061 \le m \le 3 \times 10^6.

Each of the following mm lines contains two integers aa and bb separated by a single space (1a,bn1 \le a, b \le n, aba \ne b), meaning that kid aa does not want to meet kid bb at the party. Each ordered pair appears at most once.

Output

If it is impossible to invite at least kk kids so that the party is a success, print a single line containing the word NIE.

Otherwise, print a single integer: the maximum number of kids that can be invited so that the party is a success.

Hint