package D3;
import java.util.Scanner;
public class 준홍이의카드놀이 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int tc = 1; tc<=T; tc++) {
int N = sc.nextInt();
int M = sc.nextInt();
// int arr[] = new int[N+1];
// int arr2[] = new int[M+1];
int cnt[] = new int[N+M+1];
for(int i =1; i<=N; i++) {
for(int j =1; j<=M; j++) {
cnt[i+j]++;
}
}
int max = 0;
for(int i =2; i<N+M; i++) {
if(cnt[i]>max) {
max = Math.max(cnt[i], max) ;
}
}
System.out.print("#" + tc + " " );
for(int i=2; i<=M+N; i++) {
if(cnt[i] == max)
System.out.print(i + " ");
}
System.out.println();
}
}
}