#include <stdio.h>
#include <stdlib.h>
void euclid( int a, int b, int *d ) {
if ( b == 0 ) {
*d = a;
}
else
euclid ( b, a % b, d );
}
void euclidExtins ( int a, int b, int *x, int *y ) {
if ( b == 0 ) {
*x = 1;
*y = 0;
}
else {
int x0, y0;
euclidExtins( b, a % b, &x0, &y0 );
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main() {
FILE *fin, *fout;
int t, as, bs, cs, i, d, x, y;
fin = fopen ( "euclid3.in", "r" );
fout = fopen ( "euclid3.out", "w" );
fscanf ( fin, "%d", &t );
for ( i = 0; i < t ; i++ ) {
fscanf ( fin, "%d%d%d", &as, &bs, &cs );
euclid( as, bs, &d );
if ( cs % d == 0 ) {
euclidExtins( as, bs, &x, &y );
fprintf ( fout, "%d %d\n", x * ( cs / d ), y * ( cs / d ) );
}
else
fprintf ( fout, "0 0\n" );
}
fclose ( fin );
fclose ( fout );
return 0;
}