C - Cat Snuke and a Voyage Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 300300

問題文

高橋キングダムには、高橋諸島という、NN 個の島からなる諸島があります。 便宜上、これらの島を島 11、島 22、 ...、島 NN と呼ぶことにします。

これらの諸島の間では、船の定期便が MM 種類運行されています。 定期便はそれぞれ 22 つの島の間を行き来しており、ii 種類目の定期便を使うと、 島 aia_i と島 bib_i の間を行き来する事ができます。

すぬけくんは今島 11 にいて、島 NN に行きたいと思っています。 しかし、島 11 から島 NN への定期便は存在しないことがわかりました。 なので、定期便を 22 つ使うことで、島 NN に行けるか調べたいと思っています。

これを代わりに調べてあげてください。

制約

  • 3N200,0003 ≦ N ≦ 200,000
  • 1M200,0001 ≦ M ≦ 200,000
  • 1ai<biN1 ≦ a_i < b_i ≦ N
  • (ai,bi)(1,N)(a_i, b_i) \neq (1, N)
  • iji \neq j ならば (ai,bi)(aj,bj)(a_i, b_i) \neq (a_j, b_j)

入力

入力は以下の形式で標準入力から与えられる。

NN MM
a1a_1 b1b_1
a2a_2 b2b_2
:
aMa_M bMb_M

出力

定期便を 22 つ使いたどり着けるならば POSSIBLE、たどり着けないならば IMPOSSIBLE と出力する。


入力例 1Copy

Copy
3 2
1 2
2 3

出力例 1Copy

Copy
POSSIBLE

入力例 2Copy

Copy
4 3
1 2
2 3
3 4

出力例 2Copy

Copy
IMPOSSIBLE

44 へ行くには、定期便を 33 つ使う必要があります。


入力例 3Copy

Copy
100000 1
1 99999

出力例 3Copy

Copy
IMPOSSIBLE

入力例 4Copy

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

出力例 4Copy

Copy
POSSIBLE

11、島 44、島 55 と移動すれば 22 つの定期便で移動可能です。

Score : 300300 points

Problem Statement

In Takahashi Kingdom, there is an archipelago of NN islands, called Takahashi Islands. For convenience, we will call them Island 11, Island 22, ..., Island NN.

There are MM kinds of regular boat services between these islands. Each service connects two islands. The ii-th service connects Island aia_i and Island bib_i.

Cat Snuke is on Island 11 now, and wants to go to Island NN. However, it turned out that there is no boat service from Island 11 to Island NN, so he wants to know whether it is possible to go to Island NN by using two boat services.

Help him.

Constraints

  • 3N2003 ≤ N ≤ 200 000000
  • 1M2001 ≤ M ≤ 200 000000
  • 1ai<biN1 ≤ a_i < b_i ≤ N
  • (ai,bi)(1,N)(a_i, b_i) \neq (1, N)
  • If iji \neq j, (ai,bi)(aj,bj)(a_i, b_i) \neq (a_j, b_j).

Input

Input is given from Standard Input in the following format:

NN MM
a1a_1 b1b_1
a2a_2 b2b_2
:
aMa_M bMb_M

Output

If it is possible to go to Island NN by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.


Sample Input 1Copy

Copy
3 2
1 2
2 3

Sample Output 1Copy

Copy
POSSIBLE

Sample Input 2Copy

Copy
4 3
1 2
2 3
3 4

Sample Output 2Copy

Copy
IMPOSSIBLE

You have to use three boat services to get to Island 44.


Sample Input 3Copy

Copy
100000 1
1 99999

Sample Output 3Copy

Copy
IMPOSSIBLE

Sample Input 4Copy

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

Sample Output 4Copy

Copy
POSSIBLE

You can get to Island 55 by using two boat services: Island 11 -> Island 44 -> Island 55.



2025-04-07 (Mon)
23:21:05 +00:00