Let's call an undirected graph G=(V,E)G=(V,E) relatively prime if and only if for each edge (v,u)∈E(v,u)∈E  GCD(v,u)=1GCD(v,u)=1 (the greatest common divisor of vv and uu is 11). If there is no edge between some pair of vertices vv and uu then the value of GCD(v,u)GCD(v,u) doesn't matter. The vertices are numbered from 11 to |V||V|.

Construct a relatively prime graph with nn vertices and mm 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 nn and mm (1≤n,m≤1051≤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 ii-th of the next mm lines should contain the ii-th edge (vi,ui)(vi,ui) of the resulting graph (1≤vi,ui≤n,vi≠ui1≤vi,ui≤n,vi≠ui). For each pair (v,u)(v,u)there can be no more pairs (v,u)(v,u) or (u,v)(u,v). The vertices are numbered from 11 to nn.

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:

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

暴力枚举一遍就行了

 #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + ;
const int INF = 0x3fffffff;
typedef long long LL;
using namespace std;
int n, m;
struct node {
int x, y;
node () {}
node (int x, int y): x(x), y(y) {}
} qu[maxn];
int main() {
scanf("%d%d", &n, &m);
if (n - > m) {
printf("Impossible\n");
return ;
}
int k = , flag = ;
for (int i = ; i <= n ; i++) {
for (int j = i + ; j <= n ; j++) {
if (__gcd(i, j) == ) qu[k++] = node(i, j);
if (k == m) {
flag = ;
break;
}
}
if (flag) break;
}
if (flag) {
printf("Possible\n");
for (int i = ; i < k ; i++)
printf("%d %d\n", qu[i].x, qu[i].y);
} else printf("Impossible\n");
return ;
}

D. Relatively Prime Graph的更多相关文章

  1. Codeforces 1009D:Relatively Prime Graph

    D. Relatively Prime Graph time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. Relatively Prime Graph CF1009D 暴力 思维

    Relatively Prime Graph time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  3. Codeforces Global Round 4 Prime Graph CodeForces - 1178D (构造,结论)

    Every person likes prime numbers. Alice is a person, thus she also shares the love for them. Bob wan ...

  4. [Codeforces 1178D]Prime Graph (思维+数学)

    Codeforces 1178D (思维+数学) 题面 给出正整数n(不一定是质数),构造一个边数为质数的无向连通图(无自环重边),且图的每个节点的度数为质数 分析 我们先构造一个环,每个点的度数都是 ...

  5. CodeForces - 1009D Relatively Prime Graph

    题面在这里! 直接暴力找点对就行了,可以证明gcd=1是比较密集的,所以复杂度略大于 O(N log N) #include<bits/stdc++.h> #define ll long ...

  6. Educational Codeforces Round 47 (Rated for Div. 2) :D. Relatively Prime Graph

    题目链接:http://codeforces.com/contest/1009/problem/D 解题心得: 题意就是给你n个点编号1-n,要你建立m条无向边在两个互质的点之间,最后所有点形成一个连 ...

  7. 【Codeforces 1009D】Relatively Prime Graph

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 1000以内就有非常多组互质的数了(超过1e5) 所以,直接暴力就行...很快就找完了 (另外一开始头n-1条边找1和2,3...n就好 [代 ...

  8. CF1178D Prime Graph

    题目链接 题意 构造一张有\(n(3\le n\le 1000)\)个点的无向图(无重边和自环).满足: 边的总数为素数 所有点的度数均为素数 输出方案 solution 如果所有点的度数确定了.那么 ...

  9. Codeforces 1178D. Prime Graph

    传送门 首先每个点至少要有两条边连接 那么容易想到先保证这一点然后再慢慢加边 那么先构成一个环即可:$(1,2),(2,3),(3,4)...(n,1)$ 然后考虑加边,发现一个点加一条边还是合法的, ...

随机推荐

  1. PyCharm使用秘籍视频

    PyCharm使用视频上传至企鹅群公告 需要自行添加群获取

  2. Jetson tx1 安装cuda错误

    前两天安装Jetpack3.0的时候,看着网上的教程以为cuda会自动安装上,但是历经好几次安装,都安装不上cuda,也刷了好几次jetpack包.搜遍了网上的教程,也没有安装上.错误如下图所示: 这 ...

  3. Python3爬虫(十) 数据存储之非关系型数据库MongoDB

    Infi-chu: http://www.cnblogs.com/Infi-chu/ 一.非关系型数据库NoSQL全程是Not Only SQL,非关系型数据库.NoSQL是基于键值对的,不需要经过S ...

  4. Rmarkdown:输出pdf设置

    输出pdf需要安装Ctex --- title: "first markdown" author: "name" date: "`r format(S ...

  5. Ubantu E325 错误的解决办法

    这个错误是由于未正确关闭文本编辑器导致的: 图一 解决办法:退出后输入 sudo vim /etc/hosts 图二 直接输入 D 即可! 注意:退出文本编辑器的正确方式是:ESC键 + :wq. 我 ...

  6. 从C到C++ (3)

    从C到C++ (3) 一.    C++中增加了引用 1.引用是给某一个变量起别名.引用的一般格式: 类型 &引用名 = 变量名 定义引用时一定要初始化.在实际应用中,引用一般用作参数传递与返 ...

  7. 问题:docker pull 用户登陆tricky,Error response from daemon: unauthorized: incorrect username or password

    问题描述: PS C:\WINDOWS\system32> docker pull rabbitmqUsing default tag: latest Please login prior to ...

  8. PostgreSQL基本配置

    记一下Postgresql的基本操作,在Ubuntu下使用apt-get安装是不会像MySQL那样都配置好了,而是要安装后再配置: 1. 基本安装 # 安装postgresql和pgadmin(一个管 ...

  9. 问题 A: 完数

    问题 A: 完数 时间限制: 1 Sec  内存限制: 32 MB提交: 252  解决: 178[提交][状态][讨论版][命题人:外部导入] 题目描述 求1-n内的完数,所谓的完数是这样的数,它的 ...

  10. Queue模块初识

    Queue模块实现了多生产者.多消费者队列.它特别适用于信息必须在多个线程间安全地交换的多线程程序中.这个模块中的Queue类实现了所有必须的锁语义.它依赖于Python中线程支持的可用性:参见thr ...