Let's call an undirected graph |V|.

Construct a relatively prime graph with m edges such that it is connected and it contains neither self-loops nor multiple edges.

If there exists no valid graph with the given number of vertices and edges then output "Impossible".

If there are multiple answers then print any of them.

Input

The only line contains two integers 1≤n,m≤105) — the number of vertices and the number of edges.

Output

If there exists no valid graph with the given number of vertices and edges then output "Impossible".

Otherwise print the answer in the following format:

The first line should contain the word "Possible".

The n.

If there are multiple answers then print any of them.

Examples
input
Copy
5 6
output
Copy
Possible
2 5
3 2
5 1
3 4
4 1
5 4
input
Copy
6 12
output
Copy
Impossible
Note

Here is the representation of the graph from the first example:D. Relatively Prime Graph

 

   这题无脑暴力 暴力真的出了奇迹 

   暴力枚举一遍就行了

 

    

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int maxn = 1e5 + 10;
 4 const int INF = 0x3fffffff;
 5 typedef long long LL;
 6 using namespace std;
 7 int n, m;
 8 struct node {
 9     int x, y;
10     node () {}
11     node (int x, int y): x(x), y(y) {}
12 } qu[maxn];
13 int main() {
14     scanf("%d%d", &n, &m);
15     if (n - 1 > m) {
16         printf("Impossible\n");
17         return 0;
18     }
19     int k = 0, flag = 0;
20     for (int i = 1 ; i <= n ; i++) {
21         for (int j = i + 1 ; j <= n ; j++) {
22             if (__gcd(i, j) == 1) qu[k++] = node(i, j);
23             if (k == m) {
24                 flag = 1;
25                 break;
26             }
27         }
28         if (flag) break;
29     }
30     if (flag) {
31         printf("Possible\n");
32         for (int i = 0 ; i < k ; i++)
33             printf("%d %d\n", qu[i].x, qu[i].y);
34     } else  printf("Impossible\n");
35     return 0;
36 }

 

相关文章:

  • 2021-09-22
  • 2021-09-28
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-02-19
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2022-02-22
  • 2022-12-23
相关资源
相似解决方案