-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntprob6.java
More file actions
50 lines (45 loc) · 1.56 KB
/
Copy pathIntprob6.java
File metadata and controls
50 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.*;
public class Intprob6{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int x=sc.nextInt();
int y=sc.nextInt();
int n=x+y;
if(n%2==0){
if (x>=1 && y>=x){
System.out.println("YES");
int nextnode=2;
for(int i=0;i<x-1;i++){
int u=nextnode++;
int v=nextnode++;
System.out.println(1+" "+u);
System.out.println(u+" "+v);
}
while(nextnode<=n){
System.out.println(1+" "+nextnode);
nextnode++;
}
}else
System.out.println("NO");
}else{
if(y>x){
System.out.println("YES");
int nextnode=2;
for(int i=0;i<x;i++){
int u=nextnode++;
int v=nextnode++;
System.out.println(1+" "+u);
System.out.println(u+" "+v);
}
while(nextnode<=n){
System.out.println(1+" "+nextnode);
nextnode++;
}
}else
System.out.println("NO");
}
}
}
}