水题…
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while (n-->0) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int i = (1000/a+1)*a;
for (; i < 10000; i+=a) {
if ((i+1)%b==0 && (i+2)%c==0) {
System.out.println(i);
break;
}
}
if (i>=10000) {
System.out.println("Impossible");
}
}
sc.close();
}
}