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; } void pre(long[] a,long[] m) { int n=a.length; for (int i=0;i1) { m[j]/=g; a[j]%=m[j]; } else { m[i]/=g; a[i]%=m[i]; } } } } long garner(long[] a,long[] m) { pre(a,m); long ret=0,prd=1; for (int i=0;iD_*denominator) continue; long sign_x=(vx_/denominator*T+sx_); long sign_y=(vy_/denominator*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