import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.NoSuchElementException; public class Main { long euclid(long x,long y,long a,long b) { return a==0?y:euclid(y-b/a*x,x,b%a,a); } long inv(long a,long m) { if (a%m==0) return 0; long v=euclid(1, 0, (a%m+m)%m, m); return v<0?v+m:v; } long gcd(long a,long b) { return a==0?Math.abs(b):gcd(b%a,a); } long lcm(long a,long b) { return a/gcd(a,b)*b; } long pow(long a,long n,long p) { return n!=0?(pow(a,n/2,p)*(n%2==1?a:1)):1; } long garner(long[] a,long[] m) { long ret=0,prd=1; for (int i=0;iD_*numerator) continue; long sign_x=(vx_/numerator*T+sx_); long sign_y=(vy_/numerator*T+sy_); if (sign_x<0) sign_x-=W_; if (sign_y<0) sign_y-=H_; if (Math.abs(sign_x)/W_%2!=i) continue; if (Math.abs(sign_y)/H_%2!=j) continue; ans|=true; } } } return ans; } void run() { FastScanner sc=new FastScanner(); PrintWriter pw=new PrintWriter(System.out); int Q=sc.nextInt(); for (int q=0;q