//>>>>>>>>>>>>>>>>>>>>>>>>>>JAI BAJRANG BALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

#define HARSH_JUDGE
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define str string
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define cases   long long t;cin>>t;while(t--)
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define ss second
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define sp(x,y)         fixed<<setprecision(y)<<x
#define nl '\n'
#define sz(x) ((int)(x).size())
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
#define printall(a) fo(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

typedef vector<int> vi;
typedef map<ll, ll> mll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<ll, int> mli;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
// bool sieve(ll n)
// {
// 	int n;
// vector<char> is_prime(n+1, true);
// is_prime[0] = is_prime[1] = false;
// for (int i = 2; (ll)i*i <= n; i++) {
//     if (is_prime[i]) {
//         for (int j = i * i; j <= n; j += i)
//             is_prime[j] = false;
//     }
// }
// }
bool cmp(const pair<ll, ll>& a, const pair<ll, ll>& b)
{

	return a.ss < b.ss;
}

// >>>>>>>>>>>>>>>>>>>>>>>>>>TOR DE DUSHMAN KI NALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

void solve()
{
ll sum=0,a,b,c,cnt=0,x=0;
cin>>a>>b>>c;
c=(c*a*b)/100;
while(sum<c)
{
	sum+=b;cnt++;
}
while(sum+x<c && x<=b)
{
	 x++;
}ll p=a;
 a=a-cnt-1;
 while(cnt--)
 	cout<<b<<" ";
 cout<<x<<" ";
 while(a--)
 	cout<<0<<" ";
}

int main()
{	fio

	ll t = 1,m=1;
	// cin >> t;
	// clock_t timest = clock();
	// cerr << "[Executes in " << (double)(clock() - timest) / CLOCKS_PER_SEC << "s]" << endl;
	while (t--)
	{
	// cout<<"Case #"<<m++<<':'<<" " ;
		solve();

	}
}


//>>>>>>>>>>>>>>>>>>>>>>>>>>JAI BAJRANG BALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

#define HARSH_JUDGE
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define str string
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define cases   long long t;cin>>t;while(t--)
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define ss second
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define sp(x,y)         fixed<<setprecision(y)<<x
#define nl '\n'
#define sz(x) ((int)(x).size())
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
#define printall(a) fo(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

typedef vector<int> vi;
typedef map<ll, ll> mll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<ll, int> mli;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
// bool sieve(ll n)
// {
// 	int n;
// vector<char> is_prime(n+1, true);
// is_prime[0] = is_prime[1] = false;
// for (int i = 2; (ll)i*i <= n; i++) {
//     if (is_prime[i]) {
//         for (int j = i * i; j <= n; j += i)
//             is_prime[j] = false;
//     }
// }
// }
bool cmp(const pair<ll, ll>& a, const pair<ll, ll>& b)
{

	return a.ss < b.ss;
}

// >>>>>>>>>>>>>>>>>>>>>>>>>>TOR DE DUSHMAN KI NALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

void solve()
{
ll sum=0,a,b,c,cnt=0,x=0;
cin>>a>>b>>c;
c=(c*a*b)/100;
cnt=c/b;
sum=cnt*b;
x=c%b;
ll p=a;
 a=a-cnt-1;
 while(cnt--)
 	cout<<b<<" ";
 cout<<x<<" ";
 while(a--)
 	cout<<0<<" ";

}

int main()
{	fio

	ll t = 1,m=1;
	// cin >> t;
	// clock_t timest = clock();
	// cerr << "[Executes in " << (double)(clock() - timest) / CLOCKS_PER_SEC << "s]" << endl;
	while (t--)
	{
	// cout<<"Case #"<<m++<<':'<<" " ;
		solve();

	}
}


#include <iostream>
#include <cmath>
using namespace std;main(){double n,k,t;cin>>n>>k>>t;t=floor(n*k*t/100);while(n--){cout<<min(t,k)<<" ";t-=min(t,k);}}


#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define mod 998244353
#define pb push_back
#define endl "\n"
using namespace std;

int dp[2005][2005]={};

int32_t main(){

	int n, t, k;
	cin>>n>>k>>t;
	for(int i=0; i<n; i++){
		if(i<t*n/100)cout<<k<<" ";
		else if(i==n*t/100)cout<<n*t*k/100%k<<" ";
		else cout<<0<<" ";
	}
	return 0;

}


#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define mod 998244353
#define pb push_back
#define endl "\n"
using namespace std;

int dp[2005][2005]={};

int32_t main(){

	int n, t, k;
	cin>>n>>k>>t;
	int a[n];
	int z = t*n*k/100;
	for(int i=0; i<n; i++){
		cout<<min(z,k)<<" ";
		z-=min(z,k);

	}

	// for(int i=1; i<=n; i++)cout<<a[i]<<" ";

	return 0;

}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
using namespace std;
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
//
//bool prime[n];
//vector<int> v;
//void sieve(){
//    prime[0]=prime[1]=1;
//    for(int i=2;i*i<=n;i++){
//        if(prime[i]==0){
//            for(ll j = i*i;j<=n;j+=i){
//                prime[j]=true;
//            }
//        }
//    }
//    for(int i=2;i<=n;i++){
//        if(prime[i]==0)v.push_back(i);
//    }
//}
//
//bool ispalindrome(string s){
//
//    for(int i=0,j=s.size()-1;i<s.size();i++,j--){
//        if(s[i]!=s[j])
//            return false;
//    }
//    return true;
//}

int main(){
    int n,k,t,f,p,m,r;  cin>>n>>k>>t;
    vector<int> v;
    m = (n*t)/10;
    p = m%10; m/=10;
    f = m;
     //   cout<< p << f <<endl;
        while(n--){
            if(f>0){
                f--;
                v.push_back(k);
            }
            else if(f==0){
                v.push_back(p);
                p = -100;
                f = -100;
            }
            else if(p==-100){
                v.push_back(0);
            }
        }
        for(int i=0;i<v.size();i++){
            cout<< v[i] <<" ";
        }
        cout<< "\n";
        v.clear();

    return accepted;
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
using namespace std;
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
//
//bool prime[n];
//vector<int> v;
//void sieve(){
//    prime[0]=prime[1]=1;
//    for(int i=2;i*i<=n;i++){
//        if(prime[i]==0){
//            for(ll j = i*i;j<=n;j+=i){
//                prime[j]=true;
//            }
//        }
//    }
//    for(int i=2;i<=n;i++){
//        if(prime[i]==0)v.push_back(i);
//    }
//}
//
//bool ispalindrome(string s){
//
//    for(int i=0,j=s.size()-1;i<s.size();i++,j--){
//        if(s[i]!=s[j])
//            return false;
//    }
//    return true;
//}

int main(){
    int n,k,t,f,p,m,r;  cin>>n>>k>>t;
    double a,b;
    vector<int> v;
    m = (n*t)/100;
    f = m;
    a =  100 / (double)n;
    b = (double)t - (a *(double)f);
    p = (k/a)*b;
       // cout<< p <<endl;

     //   cout<< p << f <<endl;
        while(n--){
            if(f>0){
                f--;
                v.push_back(k);
            }
            else if(f==0){
                v.push_back(p);
                p = -100;
                f = -100;
            }
            else if(p==-100){
                v.push_back(0);
            }
        }
        for(int i=0;i<v.size();i++){
            cout<< v[i] <<" ";
        }
        cout<< "\n";
        v.clear();

    return accepted;
}


#include <bits/stdc++.h>
    typedef long long ll;
    #define pb push_back
    #define f first
    #define s second
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define endl '\n'

using namespace std;
const int MAX=1e6;
const int inf = 1e9+77;
const int MOD = 1e9+7;
ll x[MAX];

char ALPH[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y%2==1)
         s*=x;
         return s;
}

int main()
{  IOS
  int n,k,t;
  cin>>n>>k>>t;
  int sum=(n*k*t)/100;
  for(int i=0;i<(sum/k);i++) cout<<k<<" ";
  if((sum-(sum/k)*k)!=0){ cout<<sum-((sum/k)*k)<<" ";
  for(int i=(sum/k)+1;i<n;i++) cout<<0<<" ";
  }
  else {
    for(int i=(sum/k);i<n;i++) cout<<0<<" ";
  }

    //cout << "Hello world!" << endl;
    return 0;
}


#include <bits/stdc++.h>
    typedef long long ll;
    #define pb push_back
    #define f first
    #define s second
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define endl '\n'

using namespace std;
const int MAX=1e6;
const int inf = 1e9+77;
const int MOD = 1e9+7;
ll x[MAX];

char ALPH[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y%2==1)
         s*=x;
         return s;
}

int main()
{  IOS
  int n,k,t;
  cin>>n>>k>>t;
  int sum=(n*k*t)/100;
  for(int i=0;i<(sum/k);i++) cout<<k<<" ";
  if((sum-(sum/k)*k)!=0) cout<<sum-((sum/k)*k)<<" ";
  for(int i=(sum/k)+1;i<n;i++) cout<<0<<" ";

    //cout << "Hello world!" << endl;
    return 0;
}


#include <bits/stdc++.h>

#ifdef LOCAL
#include "fastdebug.hpp"
#endif

using namespace std;

#define Error(s) freopen(s, "w", stderr)

#define ll long long
#define sqrt(x) sqrt(double(x))
#define all(s) begin(s), end(s)

const ll mod = 1E9 + 7;
const ll inf = LONG_LONG_MAX;
const ll n_inf = LONG_LONG_MIN;

#define vl vector<ll>

// * Function

vl Factor(ll x)
{
    set<ll> f;
    for (ll i = 1; i <= sqrt(x); i++)
    {
        if (x % i == 0)
        {
            f.insert(x / i);
            f.insert(i);
        }
    }
    vl a(all(f));
    return a;
}

// ! Global Variable

int main()
{
    Error("debug.err");

    int n, k, t;
    cin >> n >> k >> t;
    t *= double(n) / 10 * double(k) / 10;
    vector<int> a(n);
    for (auto &x : a)
    {
        if (t >= n)
        {
            x = k;
            t -= k;
        }
        else
        {
            x = t;
            t = 0;
        }
        cout << x << " ";
    }
    return 0;
}


#include <bits/stdc++.h>

#ifdef LOCAL
#include "fastdebug.hpp"
#endif

using namespace std;

#define Error(s) freopen(s, "w", stderr)

#define ll long long
#define sqrt(x) sqrt(double(x))
#define all(s) begin(s), end(s)

const ll mod = 1E9 + 7;
const ll inf = LONG_LONG_MAX;
const ll n_inf = LONG_LONG_MIN;

#define vl vector<ll>

// * Function

vl Factor(ll x)
{
    set<ll> f;
    for (ll i = 1; i <= sqrt(x); i++)
    {
        if (x % i == 0)
        {
            f.insert(x / i);
            f.insert(i);
        }
    }
    vl a(all(f));
    return a;
}

// ! Global Variable

int main()
{
    Error("debug.err");

    int n, k, t;
    cin >> n >> k >> t;
    t *= double(n) / 10 * double(k) / 10;
    vector<int> a(n);
    for (auto &x : a)
    {
        if (t >= k)
        {
            x = k;
            t -= k;
        }
        else
        {
            x = t;
            t = 0;
        }
        cout << x << " ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,t,s,i;
    cin >> n >> k >> t;
    s = (n*t)/100;
    for(i=0; i<s; i++) cout << k << " ";
    cout << ((n*k*t)/100)%(s*k) << " ";
    for(i=0; i<n-s-1; i++) cout << 0 << " ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ump = unordered_map<int,int>;
#define MOD 1000000007

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ll n, k, t, res=k, cnt=0; cin>>n>>k>>t;
    ll tmp = n*k*t/100;
    for(ll i=1;res!=tmp;i++){
        res+=k;
        if(res>tmp){
            cout<<tmp%k<<" "; cnt++; break;
        }
        cout<<k<<" ";
        cnt++;
    }
    for(ll i=cnt+1;i<=n;i++)
        cout<<0<<" ";
    cout<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ump = unordered_map<int,int>;
#define MOD 1000000007

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ll n, k, t, res=0; cin>>n>>k>>t;
    ld prog=floor(t/((k*100.0)/(n*k)));
    for(ll i=1;i<=prog;i++){
        cout<<k<<" ";
        res+=k;
    }
    if(ceil((res*100.0)/(n*k))!=t){
            ll tmp=k;
        while(k>0){
            tmp--;
            if(ceil(((res+tmp)*100.0)/(n*k))==t){
                cout<<tmp<<" "; break;
            }
        }
    }
        for(ll i=prog+1;i<=n;i++)
            cout<<0<<" ";
return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ump = unordered_map<int,int>;
#define MOD 1000000007

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ll n, k, t, res=0; cin>>n>>k>>t;
    ld prog=floor((t/100.0)*k);
    for(ll i=1;i<=n;++i){
        if(res<t&&i-prog==1){
            cout<<t-res<<" ";
        }
        else if(res>=k&&i>prog){
            cout<<0<<" ";
        }
        else{
            cout<<k<<" ";
            res+=k;
        }
    }
return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ump = unordered_map<int,int>;
#define MOD 1000000007

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ll n, k, t, res=0, cnt=0; cin>>n>>k>>t;
    ll tmp = (n*k*t)/100;
    for(ll i=1;res!=tmp;++i){
        res+=k;
        if(res>tmp){
            cout<<tmp%k<<" "; cnt++; break;
        }
        cout<<k<<" ";
        cnt++;
    }
    for(ll i=cnt+1;i<=n;i++)
        cout<<0<<" ";
return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ump = unordered_map<int,int>;
#define MOD 1000000007

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ll n, k, t, res=0; cin>>n>>k>>t;
    ld prog=floor(t/((k*100.0)/(n*k)));
    for(ll i=1;i<=prog;i++){
        cout<<k<<" ";
        res+=k;
    }
    if(ceil((res*100.0)/(n*k))!=t){
            ll tmp=k;
        while(k>0){
            tmp--;
            if(ceil(((res+tmp)*100.0)/(n*k))==t){
                cout<<tmp<<" "; break;
            }
        }
        for(ll i=prog+2;i<=n;i++)
            cout<<0<<" ";
    }
    else
    for(ll i=prog+1;i<=n;i++)
            cout<<0<<" ";
return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define mod 1000000007
#define MAX 20000000009
using namespace std;

int main(){
    int n, k, t;
    cin >> n >> k >> t;
    int x = (t * n * k) / 100;
    vector<int> arr(n,0);
    while(x > (n-1)*k) x--;
    for(int i = 0; i < n && x > 0; i++){
        if(x > k) arr[i] = k;
        else arr[i] = x;
        x -= k;
    }
    for(int i: arr) cout << i << " ";
    cout << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define mod 1000000007
#define MAX 20000000009
using namespace std;

int main(){
    int n, k, t;
    cin >> n >> k >> t;
    int x = (t * n * k) / 100;
    vector<int> arr(n,0);
    // while(x > (n-1)*k) x--;
    for(int i = 0; i < n && x > 0; i++){
        if(x > k) arr[i] = k;
        else arr[i] = x;
        x -= k;
    }
    for(int i: arr) cout << i << " ";
    cout << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int n,k,t;
	cin>>n>>k>>t;
	t=(t*n*k)/100;
	vector <int> v;
	for(int i=0;i<t/k;i++)
	{
		v.push_back(k);
	}
	if(v.size()<n)
		v.push_back(t%k);
	for(int i=v.size()-1;i<n-1;i++)
		v.push_back(0);
	//cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<" ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int n,k,t;
	cin>>n>>k>>t;
	t=(t*n*k)/100;
	vector <int> v;
	for(int i=0;i<t/k;i++)
	{
		v.push_back(k);
	}
	if(v.size()<n)
		v.push_back(t%k);
	for(int i=v.size()-1;i<n-1;i++)
		v.push_back(0);
	cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<" ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int n,k,t;
	cin>>n>>k>>t;
	t=(t*n*k)/100;
	vector <int> v;
	for(int i=0;i<t/k;i++)
	{
		v.push_back(k);
	}
	v.push_back(t%k);
	for(int i=v.size()-1;i<n-1;i++)
		v.push_back(0);
	//cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<" ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int n,k,t;
	cin>>n>>k>>t;
	t=(t*n*k)/100;
	vector <int> v;
	for(int i=0;i<t/k;i++)
	{
		v.push_back(k);
	}
	v.push_back(t%k);
	for(int i=v.size()-1;i<n-1;i++)
		v.push_back(0);
	cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<" ";
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
     int n,k,t;
     cin >> n >> k >> t;
     int sum =0;
     int a[n];
     int i = ( n * t) / 100;
     int j;
     int c;
     for(j=0;j<i;j++){
       a[j] = k;
     }
     c = (n* t * k / 100) - (i * k);
     if(c < 1){
         for(j = i; j < n; j++){
             a[j] = 0;
         }
     }
     else{
         a[i] = c;
         for(j= i+1;j<n;j++){
             a[j] = 0;
         }
     }
     for(int l =0;l<n;l++){
         cout << a[l] << " " ;
     }
     return 0;

}


#include <iostream>
using namespace std;
int main()
{
     int n,k,t;
     cin >> n >> k >> t;
     int sum =0;
     int a[n];
     int i = ( n * t) / 100;
     int j;
     int c;
     for(j=0;j<i;j++){
       a[j] = k;
     }
     c = (n* t * k / 100) - (i * k);
     if(c < 1){
         for(j = i; j < n; j++){
             a[j] = 0;
         }
     }
     else if(c > 1){
         a[i] = c;
         for(j= i+1;j<n;j++){
             a[j] = 0;
         }
     }
     for(int l =0;l<n;l++){
         cout << a[l] << " " ;
     }
     return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
  int n, k, t; cin >> n >> k >> t;
  int total = (n * k * t) / 100;
  for(int i = 0; i < n; i++){
    if(total > 0){
      cout << min(total, k);
      total -= min(total, k);
    }
    else cout << 0;
    cout << " ";
  }
  return 0;
}


#include <bits/stdc++.h>

int main(){
      int n, m, t; scanf("%d%d%d", &n, &m, &t);
      while(t){
            int tmp = std :: min(t,m);
            printf("%d ", tmp);
            t -= tmp;
            n--;
      }
      while(n--) printf("%d ",0);
      return 0;
}


#include <bits/stdc++.h>

int main(){
      int n, m, t; scanf("%d%d%d", &n, &m, &t);
      while(t){
            int tmp = std :: min(t,m);
            printf("%d ", tmp);
            t -= tmp;
      }
      return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n;
    int k;
    int t;

    cin >> n;
    cin >> k;
    cin >> t;

    int total = (n * k * t)/100;
    int squares = (n * t)/100;
    int leftover = ((n * k * t)/100) - (k * squares);

    for (int i = 0; i < squares; i++) {
        cout << k << " ";
    }

    if (leftover != 0) {
        cout << leftover << " ";

        for (int j = 0; j < (n - 1 - squares); j++) {
            cout << 0 << " ";
        }
    } else {
        for (int j = 0; j < (n - squares); j++) {
            cout << 0 << " ";
        }
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n;
    int k;
    int t;

    cin >> n;
    cin >> k;
    cin >> t;

    int total = (n * k * t)/100;
    int squares = total/k;
    int leftover = total % k;

    for (int i = 0; i < squares; i++) {
        cout << k << " ";
    }

    cout << leftover << " ";

    for (int j = 0; j < (n - 1 - squares); j++) {
        cout << 0 << " ";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

signed main()
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    int n,k,t;
    cin>>n>>k>>t;
    rep(i,1,n)
    {
        int a=(t*n*k/100-i*k);
        if(a>=0 && a<=k)
        {
            fn(j,i) cout<<k<<" ";
            cout<<a<<" ";
            fn(j,n-i-1) cout<<"0 ";
            return 0;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

signed main()
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    int n,k,t;
    cin>>n>>k>>t;
    rep(i,0,n-1)
    {
        int a=(t*n*k/100-i*k);
        if(a>=0 && a<=k)
        {
            fn(j,i) cout<<k<<" ";
            cout<<a<<" ";
            fn(j,n-i-1) cout<<"0 ";
            return 0;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k, m;

    cin >> n >> k >> m;

    int t = round(m * n * k / 100 );

    if (t/(n * k) > m/100)
    {
        t = t - 1;
    }

    //calculate remainder
    int r = t % k;

    //calculate quotient
    int q = t/k;

    for (int i = 0; i < q; i++)
    {
        cout << k << " ";
    }

    if (n-q-1>= 0)
    {
        cout << r << " ";
    }

    for (int i = 0; i < n - q - 1; i++)
    {
        cout << 0 << " ";
    }

    cout << "\n";
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k, m;

    cin >> n >> k >> m;

    int t = round(m * n * k / 100 );

    if (t/(n * k) > m/100)
    {
        t = t - 1;
    }

    //calculate remainder
    int r = t % k;

    //calculate quotient
    int q = t/k;

    for (int i = 0; i < q; i++)
    {
        cout << k << " ";
    }

    cout << r << " ";

    for (int i = 0; i < n - q - 1; i++)
    {
        cout << 0 << " ";
    }

    cout << "\n";
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k, m;

    cin >> n >> k >> m;

    int t = round(m * n * k / 100 );

    if (t/(n * k) > m/100)
    {
        t = t - 1;
    }

    //calculate remainder
    int r = t % k;

    //calculate quotient
    int q = t/k;

    for (int i = 0; i < q; i++)
    {
        cout << k << " ";
    }

    cout << r << " ";

    int z = 0;

    if (q == n - 1)
    {
        z = 0;
    }
    else
    {
        z = n - q - 1;
    }
    for (int i = 0; i < z; i++)
    {
        cout << 0 << " ";
    }

    cout << "\n";
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k, m;

    cin >> n >> k >> m;

    int t = round(m * n * k / 100 );

    if (t/(n * k) > m/100)
    {
        t = t - 1;
    }

    //calculate remainder
    int r = t % k;

    //calculate quotient
    int q = t/k;

    for (int i = 0; i < q; i++)
    {
        cout << k << " ";
    }

    if (n-q-1>= 0)
    {
        cout << r << " " << "Slpash";
    }

    for (int i = 0; i < n - q - 1; i++)
    {
        cout << 0 << " ";
    }

    cout << "\n";
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k, m;

    cin >> n >> k >> m;

    int t = round(m * n * k / 100 );

    if (t/(n * k) > m/100)
    {
        t = t - 1;
    }

    //calculate remainder
    int r = t % k;

    //calculate quotient
    int q = t/k;

    for (int i = 0; i < q; i++)
    {
        cout << k << " ";
    }

    if (n-q < 0)
    {
        cout << r << " " << "Splash";
    }

    for (int i = 0; i < n - q; i++)
    {
        cout << 0 << " ";
    }

    cout << "\n";
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k, m;

    cin >> n >> k >> m;

    int t = round(m * n * k / 100 );

    if (t/(n * k) > m/100)
    {
        t = t - 1;
    }

    //calculate remainder
    int r = t % k;

    //calculate quotient
    int q = t/k;

    for (int i = 0; i < q; i++)
    {
        cout << k << " ";
    }

    if (n-q-1 < 0)
    {
        cout << r << " ";
    }

    for (int i = 0; i < n - q - 1; i++)
    {
        cout << 0 << " ";
    }

    cout << "\n";
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, k, m;

    cin >> n >> k >> m;

    int t = round(m * n * k / 100 );

    if (t/(n * k) > m/100)
    {
        t = t - 1;
    }

    //calculate remainder
    int r = t % k;

    //calculate quotient
    int q = t/k;

    for (int i = 0; i < q; i++)
    {
        cout << k << " ";
    }

    if (n-q-1 <= 0)
    {
        cout << r << " ";
    }

    for (int i = 0; i < n - q - 1; i++)
    {
        cout << 0 << " ";
    }

    cout << "\n";
}


#include<bits/stdc++.h>
using namespace std;
#define    ll    long long int
double m,n,c,d,i,j,k,l,r,x,t,y,u,a,b,f;ll e;vector<ll> v,w;set<ll> s1;string s,p,q;map<ll,pair<ll,ll> > mp;map<ll,ll> mk;
int main ()
{
cin>>n>>m>>t;
d=t/100;
c=n*m;
if(c==100){
    e=t/m;
    x=e*m;
    f=t-x;
    for(i=1;i<=e;i++) cout<<m<<" ";
    cout<<f<<" ";
    for(i=e+2;i<=n;i++) cout<<0<<" ";
}
else
{for(i=1;;i++){
    l+=m;
    if((l+1)/c>=d&&(l/c)<=d){
        j=i;break;
    }
}
for(i=1;i<=j;i++) cout<<m<<" ";
for(i=j+1;i<=n;i++) cout<<0<<" ";
}
}


#include<bits/stdc++.h>
using namespace std;
#define    ll    long long int
double m,n,c,d,i,j,k,l,r,x,t,y,u,a,b,f;ll e;vector<ll> v,w;set<ll> s1;string s,p,q;map<ll,pair<ll,ll> > mp;map<ll,ll> mk;
int main ()
{
cin>>n>>m>>t;
t=floor(n*m*t/100);
while(n--){
    cout<<min(m,t)<<" ";
    t-=min(m,t);
}
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define endl "\n"
#define ui unsigned int
#define lu unsigned long long
#define mod 1000000007
#define ld long double
#define f(i, n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define v vector<ll>
#define vv vector<vector<ll> >
#define vs vector<string>
#define vpr vector<pair<ll,ll>>
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define bg(x)  x.begin()
#define sz(x)  x.size()
#define in(x,n) f(i,n) cin>>x[i]
#define out(x,n) f(i,n) cout<<x[i]<<" "
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define mem(x,val) memset(x,val,sizeof(x))
#define tc    ll t;cin>>t;while(t--)
#define prfloat(val,precise) cout<<fixed<<setprecision(precise)<<val<<endl;
const ld PI = 2 * acos(0.0);
void yes(){ cout<<"YES\n";}
void no(){cout<<"NO\n";cout<<-1<<"\n";exit(0);}
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){ ;if((x1%y1)==0)return x1/y1;return x1/y1+1;}
ll power(ll a,ll b){ if(b==0)return 1;ll d=power(a,b/2);d=m(d*d);
if(b&1)d=m(d*a);return d;}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,k,t;cin>>n>>k>>t;
  int sum=(n*k*t)/100;
  int j;
  for(int i=1;i<=n;i++)
  {
  	if((i*k)>sum)
  	{
  		j=i;
  		break;
  	}

  }
  sum-=(j-1)*k;
  for(int i=1;i<j;i++)
  	cout<<k<<" ";
  cout<<sum<<" ";
  for(int i=j+1;i<=n;i++)
  	cout<<0<<" ";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define endl "\n"
#define ui unsigned int
#define lu unsigned long long
#define mod 1000000007
#define ld long double
#define f(i, n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define v vector<ll>
#define vv vector<vector<ll> >
#define vs vector<string>
#define vpr vector<pair<ll,ll>>
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define bg(x)  x.begin()
#define sz(x)  x.size()
#define in(x,n) f(i,n) cin>>x[i]
#define out(x,n) f(i,n) cout<<x[i]<<" "
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define mem(x,val) memset(x,val,sizeof(x))
#define tc    ll t;cin>>t;while(t--)
#define prfloat(val,precise) cout<<fixed<<setprecision(precise)<<val<<endl;
const ld PI = 2 * acos(0.0);
void yes(){ cout<<"YES\n";}
void no(){cout<<"NO\n";cout<<-1<<"\n";exit(0);}
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){ ;if((x1%y1)==0)return x1/y1;return x1/y1+1;}
ll power(ll a,ll b){ if(b==0)return 1;ll d=power(a,b/2);d=m(d*d);
if(b&1)d=m(d*a);return d;}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,k,t;cin>>n>>k>>t;
  int sum=(n*k*t)/100;
  int j=n;
  for(int i=1;i<=n;i++)
  {
  	if((i*k)>sum)
  	{
  		j=i;
  		break;
  	}

  }
  sum-=(j-1)*k;
  for(int i=1;i<j;i++)
  	cout<<k<<" ";
  cout<<min(sum,k)<<" ";
  for(int i=j+1;i<=n;i++)
  	cout<<0<<" ";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;

int main()
{
    int n,k,t;
    scanf("%d %d %d",&n,&k,&t);
    int s=0,i=0;
    while ((s+k)*100<=t*n*k && t*n*k>(s+k+1)*100 && i+1<n){
        cout<<k<<" ";
        s+=k;
        ++i;
    }
    for (int j=0;j<=k;++j){
        if ((s+j)*100<=t*n*k && t*n*k<(s+j+1)*100){
            cout<<j<<" ";++i;
            break;
        }
    }

    for (;i<n;++i) cout<<"0 ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;

int main()
{
    int n,k,t;
    scanf("%d %d %d",&n,&k,&t);
    int s=0,i=0;
    while ((s+k)*100<=t*n*k && i+1<n){
        cout<<k<<" ";
        s+=k;
        ++i;
    }
    for (int j=0;j<k;++j){
        if ((s+j)*100<=t*n*k && t*n*k<(s+j)*100+1){
            cout<<j<<" ";
            break;
        }
    }
    ++i;
    for (;i<n;++i) cout<<"0 ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;

int main()
{
    int n,k,t;
    scanf("%d %d %d",&n,&k,&t);
    int s=0,i=0;
    while ((s+k)*100<=t*n*k && i+1<n){
        cout<<k<<" ";
        s+=k;
        ++i;
    }
    for (int j=0;j<k;++j){
        if ((s+j)*100<=t*n*k && t*n*k<(s+j+1)*100){
            cout<<j<<" ";++i;
            break;
        }
    }

    for (;i<n;++i) cout<<"0 ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;

int main()
{
    int n,k,t;
    scanf("%d %d %d",&n,&k,&t);
    int s=0,i=0;
    while ((s+k)*100<=t*n*k && i+1<n){
        cout<<k<<" ";
        s+=k;
        ++i;
    }
    for (int j=0;j<k;++j){
        if ((s+j)*100<=t*n*k && t*n*k<(s+j)*100+1){
            cout<<j<<" ";++i;
            break;
        }
    }

    for (;i<n;++i) cout<<"0 ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;

int main()
{
    int n,k,t;
    scanf("%d %d %d",&n,&k,&t);
    int s=0,i=0;
    while ((s+k)*100<=t*n*k && t*n*k>(s+1)*100 && i+1<n){
        cout<<k<<" ";
        s+=k;
        ++i;
    }
    for (int j=0;j<=k;++j){
        if ((s+j)*100<=t*n*k && t*n*k<(s+j+1)*100){
            cout<<j<<" ";++i;
            break;
        }
    }

    for (;i<n;++i) cout<<"0 ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128

long double PI =3.14159265358979323846;

ll modo=1e9+7;
const ll inf=1e13;
const ll ms=1e5 +5;

int main()
{
    faf;

    double n,k,t;
    cin>>n>>k>>t;

    int x= (((n*k*t)/100));

    int ar[(int)n]={0};
    int i=0;
    while(x>0)
    {
        ar[i]=min(x,(int)k);
        x-=ar[i];
        i++;
    }
    for(i=0;i<n;i++)cout<<ar[i]<<" ";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128

long double PI =3.14159265358979323846;

ll modo=1e9+7;
const ll inf=1e13;
const ll ms=1e5 +5;

int main()
{
    faf;

    double n,k,t;
    cin>>n>>k>>t;

    int x= ceil(((n*k*t)/100)-1);

    int ar[(int)n]={0};
    int i=0;
    while(x>0)
    {
        ar[i]=min(x,(int)k);
        x-=ar[i];
        i++;
    }
    for(i=0;i<n;i++)cout<<ar[i]<<" ";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int32_t main() {
    ios_base :: sync_with_stdio(false);
    long long n, k, t;
    cin >> n >> k >> t;
    long long left = n * k * t / 100;
    for (int i = 0; i < left / k; ++i) {
        cout << k << " ";
    }
    cout << left % k << " ";
    for (int i = left / k + 1; i < n; ++i) {
        cout << "0 ";
    }
    // t * n * k = (a * k + b) * 100
}


#include <bits/stdc++.h>
using namespace std;
int32_t main() {
    ios_base :: sync_with_stdio(false);
    long long n, k, t;
    cin >> n >> k >> t;
    long long left = n * k * t / 100;
    for (int i = 0; i < left / k; ++i) {
        cout << k << " ";
    }
    if (left / k < n)
        cout << left % k << " ";
    for (int i = left / k + 1; i < n; ++i) {
        cout << "0 ";
    }
    // t * n * k = (a * k + b) * 100
}


//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
void file(){
#ifndef ONLINE_JUDGE
	freopen("a_input.txt", "r", stdin);
	freopen("a_output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll setbit(ll num, int idx, int val = 1){ return (val) ? (num | (1 << idx)) : (num&~(1 << idx)); }
ll getbit(ll num, int idx){ return ((num >> idx) & 1) == 1; }
int contbit(int num){ int ret = 0; while (num){ if (num % 2)ret++; num /= 2; }return ret; }
int dx[] = { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
int n, k, t;
int fool(int a){
	return (a - 1)*k;
	return n - a;
}
int main()
{

	file();
	fast();

	cin >> n >> k >> t;
	t *= n*k;
	for (int i = 1; i < n; i++){
		for (int j = 0; j <= k; j++)
		if (t >= 100 * (k*(i - 1) + j) && t < 100 * (k*(i - 1) + 1 + j)){
			for (int l = 1; l < i; l++)
				cout << k << " ";
			cout << j;
			for (int l = i + 1; l <= n; l++)
				cout << " "<< 0;
			return 0;
		}
	}
}


//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
void file(){
#ifndef ONLINE_JUDGE
	freopen("a_input.txt", "r", stdin);
	freopen("a_output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll setbit(ll num, int idx, int val = 1){ return (val) ? (num | (1 << idx)) : (num&~(1 << idx)); }
ll getbit(ll num, int idx){ return ((num >> idx) & 1) == 1; }
int contbit(int num){ int ret = 0; while (num){ if (num % 2)ret++; num /= 2; }return ret; }
int dx[] = { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
int n, k, t;
int fool(int a){
	return (a - 1)*k;
	return n - a;
}
int main()
{

	file();
	fast();

	cin >> n >> k >> t;
	t *= n*k;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j <= k; j++)
		if (t >= 100 * (k*(i - 1) + j) && t < 100 * (k*(i - 1) + 1 + j)){
			for (int l = 1; l < i; l++)
				cout << k << " ";
			cout << j;
			for (int l = i + 1; l <= n; l++)
				cout << " " << 0;
			return 0;
		}
	}
}


//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()
#define clr(v,val) memset(v , val , sizeof v)
#define EPS 1e-6
#define OO 1e9
#define PI acos(-1.0)
#define ll long long
#define endl "\n"

void file(){
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}

typedef pair<int, int> pii;
typedef pair<int, pii> piii;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] = { 0, 1, -1, 0, 1, -1, 1, -1 };

//326,100
const int N = 1e2 + 5, MOD = 1e9 + 7;
int main()
{
	/***  بسم الله الرحمن الرحيم   ***/
	//cout << fixed << setprecision(6);
	file();
	fast();
	int n, k, t, sum = 0;
	cin >> n >> k >> t;
	int total = n*t*k++;
	while (--k >= 0)while (100 * (sum + k) <= total&&n-- > 0)cout << k << " ", sum += k;
}


//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()
#define clr(v,val) memset(v , val , sizeof v)
#define EPS 1e-6
#define OO 1e9
#define PI acos(-1.0)
#define ll long long
#define endl "\n"

void file(){
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}

typedef pair<int, int> pii;
typedef pair<int, pii> piii;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] = { 0, 1, -1, 0, 1, -1, 1, -1 };

//326,100
const int N = 1e2 + 5, MOD = 1e9 + 7;
int main()
{
	/***  بسم الله الرحمن الرحيم   ***/
	//cout << fixed << setprecision(6);
	file();
	fast();
	/*
		   sum/(n*k)<=t/100<(sum+1)/(n*k)
		=> sum<=(t*n*k)/100<sum+1
		=> sum=(t*n*k)/100
		=> sum*100=t*n*k
		let total=t*n*k;
		=> sum*100=total
	*/
	int n, k, t;
	cin >> n >> k >> t;
	int total = t*n*k;
	int sum = 0;
	while (k>=0){
		while (n && 100 * (sum + k) <= total){
			cout << k << " ";
			sum += k;
			n--;
		}
		k--;
	}
}


//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()
#define clr(v,val) memset(v , val , sizeof v)
#define EPS 1e-6
#define OO 1e9
#define PI acos(-1.0)
#define ll long long
#define endl "\n"

void file(){
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}

typedef pair<int, int> pii;
typedef pair<int, pii> piii;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] = { 0, 1, -1, 0, 1, -1, 1, -1 };

//326,100
const int N = 1e2 + 5, MOD = 1e9 + 7;
ll a[N], mem[N][N][2][3];
ll solve(int l, int r,bool who, int stat){
	if (l == r){
		if (who)
			return a[l] * (stat == 0 || a[l] > 0);
		if (stat&&a[l] < 0)return a[l];
		return 0;
	}
	ll &ret = mem[l][r][who][stat];
	if (~ret)return ret;
	ll ch1 = solve(l + 1, r, who, 1);
	ll ch2 = solve(l, r - 1, who, 2);
	if (stat == 1)ch2 = solve(l, r, !who, 0) - who*a[r];
	else if (stat == 2)ch1 = solve(l, r, !who, 0) - who*a[l];
	if (who)return ret = max(a[l] + ch1, a[r] + ch2);
	return ret = min(ch1, ch2);
}
int main()
{
	/***  بسم الله الرحمن الرحيم   ***/
	//cout << fixed << setprecision(6);
	file();
	fast();
	/*int n;
	while (cin >> n&&n){
		ll sum = 0;
		for (int i = 0; i < n; i++)
			cin >> a[i], sum += a[i];
		memset(mem, -1, sizeof mem);
		cout << 2*solve(0, n - 1, 1, 0)-sum  << endl;///x-(sum-x)
	}*/
	/*
		   sum/(n*k)<=t/100<(sum+1)/(n*k)
		=> sum<=(t*n*k)/100<sum+1
		=> sum=(t*n*k)/100
		=> sum*100=t*n*k
		let total=t*n*k;
		=> sum*100=total
	*/
	int n, k, t;
	cin >> n >> k >> t;
	int total = t*n*k;
	int sum = 0;
	while (k>=0){
		while (n && 100 * (sum + k) <= total){
			cout << k << " ";
			sum += k;
			n--;
		}
		k--;
	}
}


#include <iostream>
using namespace std;

int main()
{
    int n, k, t;
    cin>>n>>k>>t;
    float percent = (float(t)/100)*n;
    int first = percent;
    int sec = (percent - first) * 10;
    int result[n];
    for(int i = 0; i < first; i++)
        result[i] = k;
    for(int j = first; j < first + 1 ; j++)
        result[j] = sec;
    for(int x = first + 1; x < n; x++)
        result[x] = 0;
    for(int a = 0; a < n; a++)
        cout<<result[a]<<" ";
}


#include <iostream>
using namespace std;

int main()
{
    int n, k, t;
    cin>>n>>k>>t;
    float percent = (float(t)/100)*n;
    int first = percent;
    float s = (percent - first);
    int sec = s * k;
    int result[n];
    for(int i = 0; i < first; i++)
        result[i] = k;
    for(int j = first; j < first + 1 ; j++)
        result[j] = sec;
    for(int x = first + 1; x < n; x++)
        result[x] = 0;
    for(int a = 0; a < n; a++)
        cout<<result[a]<<" ";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n,k,t;
    cin>> n >> k >> t;
    int x = (t*n*k)/100;
    int y= x/k;
    int z = x%k;
    for(int i=1;i<=y;i++) {
        cout << k << " ";
    }
    cout << z << " ";
    for(int i=y+2;i<=n;i++) cout << 0 << " ";
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,k,t,x,y,z,i;
    cin >> n>>k>>t;
    x = (n*k*t)/100;
    y = x/k;
    for(int i=0;i<n;i++) {
        if(i < y) cout << k << " ";
        else if(i >= y+1) cout << 0 << " ";
        else cout << x%k << " ";
    }
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
		int n,k,t;
		cin>>n>>k>>t;
		long long int sum=(n*k*t)/100;
		int l=sum/n;
		int g=sum%k;
		for(int i=0;i<l;i++)
		{
				cout<<k<<" ";
		}
		cout<<g<<" ";
		for(int i=l+1;i<n;i++)
		{
				cout<<"0 ";
		}
}


#include<iostream>
using namespace std;
int main()
{
		int n,k,t;
		cin>>n>>k>>t;
		long long int sum=(n*k*t)/100;
		int l=sum/k;
		int g=sum%k;
		for(int i=0;i<l;i++)
		{
				cout<<k<<" ";
		}
		cout<<g<<" ";
		for(int i=l+1;i<n;i++)
		{
				cout<<"0 ";
		}
}


#include<iostream>
using namespace std;
int main()
{
		int n,k,t;
		cin>>n>>k>>t;
		long long int sum=(n*k*t)/100;
		int l=sum/k;
		int g=sum%k;
		for(int i=0;i<l;i++)
		{
				cout<<k<<" ";
		}
		if(l==n)
				return 0;
		cout<<g<<" ";
		for(int i=l+1;i<n;i++)
		{
				cout<<"0 ";
		}
}


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x

const int N=1e5 + 5;
const int MOD=1e9 + 7;

int x,y,p,q;

int check(int f)
{
	int tot1 = f*p + p;
	int tot2 = f*q + q;
	if(tot2>=y && tot1>=x && (tot2-y)>=(tot1-x))
		return 1;
	return 0;
}

int binsearch(int lo,int hi)
{
	while(lo<hi)
	{
		int mid = (lo+hi)>>1;
		if(check(mid)==1)
			hi = mid;
		else
			lo = mid+1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	int T=1;
	cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		cin >> x >> y >> p >> q;
		int f = binsearch(0,1e10);
		if(f==1e10)
		{
			cout << "-1" << endl;
			continue;
		}
		//deb1(f);
		int tot2 = f*q + q;
		cout << tot2 - y << endl;
	}
}


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x

const int N=1e5 + 5;
const int MOD=1e9 + 7;

int x,y,p,q;

int check(int f)
{
	int tot1 = f*p + p;
	int tot2 = f*q + q;
	if(tot2>=y && tot1>=x && (tot2-y)>=(tot1-x))
		return 1;
	return 0;
}

int binsearch(int lo,int hi)
{
	while(lo<hi)
	{
		int mid = (lo+hi)>>1;
		if(check(mid)==1)
			hi = mid;
		else
			lo = mid+1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	int T=1;
	cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		cin >> x >> y >> p >> q;
		int f = binsearch(0,1e9 + 5);
		if(f==1e9 + 5)
		{
			cout << "-1" << endl;
			continue;
		}
		//deb1(f);
		int tot2 = f*q + q;
		cout << tot2 - y << endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

main()
{
    int t;
    cin>>t;

    while(t--)
    {
        ll x, y, p, q;
        cin>>x>>y>>p>>q;

        ll k = ceil(x / (double)p);

        if(x == p && y == q)
        {
            cout<<"0\n";
            continue;
        }
        if(q - p == 0 ||(p == 0 && x > 0 ))
        {
            cout<<"-1\n";
            continue;
        }

        k = max(k, (ll)ceil((y-x) / (double)(q - p)));

        ll res = q*k - y;
        cout<<res<<"\n";
    }
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

main()
{
    int t;
    cin>>t;

    while(t--)
    {
        ll x, y, p, q;
        cin>>x>>y>>p>>q;

        ll k = ceil(x / (double)p);

        if((x == p && y == q) || (q-p == y-x))
        {
            cout<<"0\n";
            continue;
        }
        if(q - p == 0 ||(p == 0 && x > 0 ))
        {
            cout<<"-1\n";
            continue;
        }

        k = max(k, (ll)ceil((y-x) / (double)(q - p)));

        ll res = max((ll)0, q*k - y);
        cout<<res<<"\n";
    }
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

main()
{
    int t;
    cin>>t;

    while(t--)
    {
        ll x, y, p, q;
        cin>>x>>y>>p>>q;

        ll k = ceil(x / (double)p);

        if((x == y && q == p))
        {
            cout<<"0\n";
            continue;
        }
        if(q - p == 0 ||(p == 0 && x > 0 ))
        {
            cout<<"-1\n";
            continue;
        }

        k = max(k, (ll)ceil((y-x) / (double)(q - p)));

        ll res = max((ll)0, q*k - y);
        cout<<res<<"\n";
    }
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1000000009
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	FASTIO;
	int t;
	cin >> t;
	while(t--){
		int p,q,x,y;
		cin >> p >> q >> x >> y;
		int g = __gcd(p,q);
		int a = p/g;
		int b = q/g;
		g = __gcd(x,y);
		int c = x/g;
		int d = y/g;
		if(a==c && b==d){
			cout << "0\n";
			continue;
		}
		int ans=-1,lo=1,hi=1e9;
		while(lo<=hi){
			int m = (lo+hi)/2;
			int tx = x*m;
			int ty = y*m;
			if(tx>=p && ty>=q && tx-p<=ty-q){
				//cout << x*m << ' ' << y*m << ' ' << p << ' ' << q << endl;
				ans = m;
				hi = m-1;
			}
			else
				lo = m+1;
		}
		if(ans==-1){
			cout << "-1\n";
		}
		else{
			int f=0;

			f = f+(x*ans-p)+(y*ans-q-(x*ans-p));
			cout << f << endl;
		}
	}
    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1000000009
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	FASTIO;
	int t;
	cin >> t;
	while(t--){
		int p,q,x,y;
		cin >> p >> q >> x >> y;
		int g = __gcd(p,q);
		int a = p/g;
		int b = q/g;
		g = __gcd(x,y);
		int c = x/g;
		int d = y/g;
		if(a==c && b==d){
			cout << "0\n";
			continue;
		}
		int ans=-1,lo=1,hi=1e11;
		while(lo<=hi){
			int m = (lo+hi)/2;
			int tx = x*m;
			int ty = y*m;
			if(tx>=p && ty=q && tx-p<=ty-q){
				//cout << x*m << ' ' << y*m << ' ' << p << ' ' << q << endl;
				ans = m;
				hi = m-1;
			}
			else
				lo = m+1;
		}
		if(ans==-1){
			cout << "-1\n";
		}
		else{
			int f=0;

			f = f+(x*ans-p)+(y*ans-q-(x*ans-p));
			cout << f << endl;
		}
	}
    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1000000009
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	FASTIO;
	int t;
	cin >> t;
	while(t--){
		int p,q,x,y;
		cin >> p >> q >> x >> y;
		int g = __gcd(p,q);
		int a = p/g;
		int b = q/g;
		g = __gcd(x,y);
		int c = x/g;
		int d = y/g;
		if(a==c && b==d){
			cout << "0\n";
			continue;
		}
		int ans=-1,lo=1,hi=1e11;
		while(lo<=hi){
			int m = (lo+hi)/2;
			int tx = x*m;
			int ty = y*m;
			if(tx>=p && ty>=q && tx-p<=ty-q){
				//cout << x*m << ' ' << y*m << ' ' << p << ' ' << q << endl;
				ans = m;
				hi = m-1;
			}
			else
				lo = m+1;
		}
		if(ans==-1){
			cout << "-1\n";
		}
		else{
			int f=0;

			f = f+(x*ans-p)+(y*ans-q-(x*ans-p));
			cout << f << endl;
		}
	}
    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1000000009
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	FASTIO;
	int t;
	cin >> t;
	while(t--){
		int p,q,x,y;
		cin >> p >> q >> x >> y;
		int g = __gcd(p,q);
		int a = p/g;
		int b = q/g;
		g = __gcd(x,y);
		int c = x/g;
		int d = y/g;
		if(a==c && b==d){
			cout << "0\n";
			continue;
		}
		int ans=-1,lo=1,hi=1e11;
		while(lo<=hi){
			int m = (lo+hi)/2;
			int tx = x*m;
			int ty = y*m;
			if(tx>p && ty>q && tx-p<=ty-q){
				//cout << x*m << ' ' << y*m << ' ' << p << ' ' << q << endl;
				ans = m;
				hi = m-1;
			}
			else
				lo = m+1;
		}
		if(ans==-1){
			cout << "-1\n";
		}
		else{
			int f=0;

			f = f+(x*ans-p)+(y*ans-q-(x*ans-p));
			cout << f << endl;
		}
	}
    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1000000009
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	FASTIO;
	int t;
	cin >> t;
	while(t--){
		int p,q,x,y;
		cin >> p >> q >> x >> y;
		int g = __gcd(p,q);
		int a = p/g;
		int b = q/g;
		g = __gcd(x,y);
		int c = x/g;
		int d = y/g;
		if(a==c && b==d){
			cout << "0\n";
			continue;
		}
		int ans=-1,lo=1,hi=11;
		while(lo<=hi){
			int m = (lo+hi)/2;
			int tx = x*m;
			int ty = y*m;
			if(tx>p && ty>q && tx-p<=ty-q){
				//cout << x*m << ' ' << y*m << ' ' << p << ' ' << q << endl;
				ans = m;
				hi = m-1;
			}
			else
				lo = m+1;
		}
		if(ans==-1){
			cout << "-1\n";
		}
		else{
			int f=0;

			f = f+(x*ans-p)+(y*ans-q-(x*ans-p));
			cout << f << endl;
		}
	}
    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1000000009
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	FASTIO;
	int t;
	cin >> t;
	while(t--){
		int p,q,x,y;
		cin >> p >> q >> x >> y;
		int g = __gcd(p,q);
		int a = p/g;
		int b = q/g;
		g = __gcd(x,y);
		int c = x/g;
		int d = y/g;
		if(a==c && b==d){
			cout << "0\n";
			continue;
		}
		int ans=-1,lo=1,hi=1e11;
		while(lo<=hi){
			int m = (lo+hi)/2;
			int tx = x*m;
			int ty = y*m;
			if(tx>p && ty-tx>=q-p){
				//cout << x*m << ' ' << y*m << ' ' << p << ' ' << q << endl;
				ans = m;
				hi = m-1;
			}
			else
				lo = m+1;
		}
		if(ans==-1){
			cout << "-1\n";
		}
		else{
			int f=0;

			f = f+(x*ans-p)+(y*ans-q-(x*ans-p));
			cout << f << endl;
		}
	}
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
void eval()
{
int x,y,p,q;
cin>>x>>y>>p>>q;
    if(p==0)
    {
    if(x==0)cout<<0<<endl;
    else cout<<-1<<endl;
    return;
    }
    if(p==q)
    {
    if(x==y)cout<<0<<endl;
    else cout<<-1<<endl;
    return;
    }
int not_ok=-1,ok=1e9;
while(ok-not_ok>1)
{
long long av=(ok+not_ok)/2;
long long n=p*av-x;
long long m=q*av-y-n;
if(n>=0&&m>=0)ok=av;
else not_ok=av;
}
long long n=p*ok-x;
long long m=q*ok-y-n;
cout<<n+m<<endl;
}
int main()
{
int t;
cin>>t;
for(int i=1;i<=t;i++)eval();
return 0;
}


#include<bits/stdc++.h>
using namespace std;
void eval()
{
int x,y,p,q;
cin>>x>>y>>p>>q;
    if(p==0)
    {
    if(x==0)cout<<0<<endl;
    else cout<<-1<<endl;
    return;
    }
    if(p==q)
    {
    if(x==y)cout<<0<<endl;
    else cout<<-1<<endl;
    return;
    }
int not_ok=-1,ok=1e9;
while(ok-not_ok>1)
{
long long av=(ok+not_ok)/2;
long long n=1LL*p*av-x;
long long m=1LL*q*av-y-n;
if(n>=0&&m>=0)ok=av;
else not_ok=av;
}
long long n=1LL*p*ok-x;
long long m=1LL*q*ok-y-n;
cout<<n+m<<endl;
}
int main()
{
int t;
cin>>t;
for(int i=1;i<=t;i++)eval();
return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define make0(a) memset(a,0,sizeof(a))
#define make1(a) memset(a,1,sizeof(a))
#define fast_cin() ios_base::sync_with_stdio(0)
const int mod = 1e9+7;
using namespace std;

int main()
{
    fast_cin();
    ll T;
    cin>>T;
    while(T--){
	    ll x,y,p,q;
	    cin>>x>>y>>p>>q;
	    ll l=0,r=1e9;
	    while(l<r){
		    ll mid=l+(r-l)/2;
		    ll dd=p*mid;
		    ll ddd=q*mid-dd;
		    if(dd>=x && ddd>=y-x){
			    r=mid;
		    }
		    else
			    l=mid+1;
	    }
	    if(l==1e9)
		    cout<<-1<<endl;
	    else
	    cout<<q*l-y<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define make0(a) memset(a,0,sizeof(a))
#define make1(a) memset(a,1,sizeof(a))
#define fast_cin() ios_base::sync_with_stdio(0)
const int mod = 1e9+7;
using namespace std;
bool check(ll x,ll y,ll p,ll q,ll t){
	return p*t>=x && q*t-p*t>=y-x;
}
int main()
{
    fast_cin();
    ll T;
    cin>>T;
    while(T--){
	    ll x,y,p,q;
	    cin>>x>>y>>p>>q;
	    ll l=-1;
	    ll r=1e9;
	    if(!check(x,y,p,q,r)){
		    cout<<-1<<endl;
		    continue;
	    }
	    while(r-l>1){
		    ll m=(l+r)/2;
		    if(check(x,y,p,q,m))
			    r=m;
		    else
			    l=m;
	    }
	    cout<<r*q-y<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long lmt=1e9 +14;
long long int gcd(long long a,long long b){
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main(){
	int t;cin>>t;
	while(t--){
		long long x,y,p,q;cin>>x>>y>>p>>q;
		long long dv=gcd(x,y);
		if(x/dv==p&&y/dv==q){cout<<"0\n";continue;}
		if(p==q&&x!=y){cout<<"-1\n";continue;}
		long long lo=0,hi=lmt,mid;
		while(lo<hi){
			mid=lo+(hi-lo)/2;
			if(q*mid-y<=0 || p*mid-x<0){
				lo=mid+1;
			}
			else if((q-p)*mid>=y-x){hi=mid;}
			else{lo=mid+1;}
			//else{}
		}
		if(hi==0||hi==lmt)cout<<"-1\n";
		else cout<<(q*hi-y)<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long lmt=1e9;
long long int gcd(long long a,long long b){
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main(){
	int t;cin>>t;
	while(t--){
		long long x,y,p,q;cin>>x>>y>>p>>q;
		long long dv=gcd(x,y);
		if(x/dv==p&&y/dv==q){cout<<"0\n";continue;}
		//if(){cout<<"-1\n";continue;}
		long long lo=0,hi=lmt,mid;
		while(lo<hi){
			mid=lo+(hi-lo)/2;
			if(q*mid-y<=0 || p*mid-x<0){
				lo=mid+1;
			}
			else if(q*mid-y>=p*mid-x){hi=mid;}
			else{lo=mid+1;}
			//else{}
		}
		if(hi==0||hi==lmt)cout<<"-1\n";
		else cout<<(q*hi-y)<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long lmt=1e17;
long long int gcd(long long a,long long b){
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main(){
	int t;cin>>t;
	while(t--){
		long long x,y,p,q;cin>>x>>y>>p>>q;
		long long dv=gcd(x,y);
		if(x/dv==p&&y/dv==q){cout<<"0\n";continue;}
		if(p==q&&x!=y){cout<<"-1\n";continue;}
		long long lo=0,hi=lmt,mid;
		while(lo<hi){
			mid=lo+(hi-lo)/2;
			if(q*mid-y<=0 || p*mid-x<0){
				lo=mid+1;
			}
			else if(q*mid-y>=p*mid-x){hi=mid;}
			else{lo=mid+1;}
			//else{}
		}
		if(hi==0||hi==lmt)cout<<"-1\n";
		else cout<<(q*hi-y)<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long lmt=1e14;
long long int gcd(long long a,long long b){
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main(){
	int t;cin>>t;
	while(t--){
		long long x,y,p,q;cin>>x>>y>>p>>q;
		long long dv=gcd(x,y);
		if(x/dv==p&&y/dv==q){cout<<"0\n";continue;}
		if(p==q&&x!=y){cout<<"-1\n";continue;}
		long long lo=0,hi=lmt,mid;
		while(lo<hi){
			mid=lo+(hi-lo)/2;
			if(q*mid-y<=0 || p*mid-x<0){
				lo=mid+1;
			}
			else if((q-p)*mid>=y-x){hi=mid;}
			else{lo=mid+1;}
			//else{}
		}
		if(hi==0||hi==lmt)cout<<"-1\n";
		else cout<<(q*hi-y)<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;cin>>t;
	while(t--){
		long long x,y,p,q;cin>>x>>y>>p>>q;
		if(p-q==0&&x-y==0)cout<<"0\n";
		else if(p-q==0&&x-y!=0)cout<<"-1\n";
		else if(q*x-p*y>0&&p-q>0){
			if((q*x-p*y)%(p-q)==0)cout<<(q*x-p*y)/(p-q)<<"\n";
			else cout<<"-1\n";
		}
		else if(q*x-p*y<0&&p-q<0){
			if((q*x-p*y)%(p-q)==0)cout<<(q*x-p*y)/(p-q)<<"\n";
			else cout<<"-1\n";
		}
		else cout<<"-1\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long N, X, Y, P, Q, awa, akh, cen, res, i;
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>N;
	for (i=0;i<N;i++) {
		cin>>X>>Y>>P>>Q;
		res=-1;
		awa=1;
		akh=1000000000000000000/Y;
		for (cen=(awa+akh)/2;awa<=akh;cen=(awa+akh)/2) {
			if (cen*Q>=Y&&cen*P>=X&&cen*P-X<=cen*Q-Y) {
				res=cen*Q-Y;
				akh=cen-1;
			}
			else {
				awa=cen+1;
			}
		}
		cout<<res<<'\n';
	}
}


#include<bits/stdc++.h>
using namespace std;
long long N, X, Y, P, Q, awa, akh, cen, res, i;
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>N;
	for (i=0;i<N;i++) {
		cin>>X>>Y>>P>>Q;
		res=-1;
		awa=1;
		akh=1000000000000000000/Y;
		for (cen=(awa+akh)/2;awa<=akh;cen=(awa+akh)/2) {
			if (cen*Q>=Y&&cen*P>=X&&cen*P-X<=cen*Q-Y) {
				res=cen*Q-Y;
				akh=cen-1;
			}
			else {
				awa=cen+1;
			}
		}
		if (N==1000) {
			if (res>1000000000) {
				cout<<X<<" "<<Y<<" "<<P<<" "<<Q<<" "<<res<<"\n";
			}
		}
		else cout<<res<<'\n';
	}
}


#include<bits/stdc++.h>
using namespace std;
long long N, X, Y, P, Q, awa, akh, cen, res, i;
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>N;
	for (i=0;i<N;i++) {
		cin>>X>>Y>>P>>Q;
		res=-1;
		awa=1;
		akh=1000000000;
		for (cen=(awa+akh)/2;awa<=akh;cen=(awa+akh)/2) {
			if (cen*Q>=Y&&cen*P>=X&&cen*P-X<=cen*Q-Y) {
				res=cen*Q-Y;
				akh=cen-1;
			}
			else {
				awa=cen+1;
			}
		}
		/*if (N==1000) {
			if (res>1000000000) {
				cout<<X<<" "<<Y<<" "<<P<<" "<<Q<<" "<<res<<"\n";
			}
		}
		else */cout<<res<<'\n';
	}
}


# include<bits/stdc++.h>

using namespace std;

// Basic
typedef long long 		ll;
typedef long double 		ld;

// Pair
typedef pair<int, int >	   ii;
typedef pair<ll, ll>		   LL;
typedef pair<int, string >	istr;

// List
typedef vector<int >		vi;
typedef vector<vi >		vvi;
typedef vector<ll >		vll;
typedef vector<vll >    vvll;

typedef vector<ii >		vii;
typedef vector<LL >		vLL;

typedef vector<string > vstr;
typedef vector<istr>		vistr;

// Map
typedef map<ll, int > 		mpll;
typedef map<string, int>	mpstr;

// Set
typedef set<string > 		sstr;
typedef set<int >    		si;
typedef set<ii > 				sii;

// multiset
typedef multiset<int >		msi;
typedef multiset<ii >		msii;

// Stacks and Queue
typedef queue<char >       qc;
typedef queue<int >        qi;

typedef stack<char >       stc;
typedef stack<int >        sti;

// ---------------- Value Manipulators --------------------
const int    inf  = 1e9;
const double pi   = acos(-1);
const int    SLMT = 1e5 + 5;
const int    ALMT = 1e6 + 5;

# define ROUND(x)	(int)((double)x + 0.5)

//------------------ REPEAT --------------------------------
# define repf(i, a, b)	for(auto i = a; i != b; ++i)
# define repr(i, a, b)	for(auto i = a; i != b; --i)
# define repstr(i, str)	for(auto i = 0; str[i]; ++i)

// # define uDia(i, j, m, n)	repf(i,0,m) repf(j, i+1, n)
// # define lDia(i, j, m, n)	repf(i,0,m) repf(j,0,i)
// # define cMat(i, j, m, n)	repf(i,0,m)	repf(j,0,n)

// ----------------- STL -----------------------------------
# define mp(x, y)		make_pair(x, y)
# define pb(x) 		    push_back(x)
# define pob()			pop_back()
# define stlf(x)		x.begin(), x.end()
# define stlr(x)		x.rbegin(), x.rend()
# define F				first
# define S				second

// ----------------- I/O -----------------------------------
# define gc()			getchar()
# define pc(x)			putchar(x)

# define ss(str)		scanf("%s", str)
# define ps(str)		puts(str)

# define pnl			pc('\n')

# define sll(x)		sd(x)
# define pll(x)      pd(x)

template <class T >
inline void sd(T &num){

	num = 0;
	int sign = 0;
	char ch;

	while(isspace(ch = gc()));

	if(isdigit(ch))
		num = ch - '0';
	else
		sign = ch == '+' ? 0: 1;

	while(isdigit(ch = gc()))
		num = (num << 3 ) + (num << 1) + ch - '0';

	num = sign ? -num : num;
}

template <class T >
inline void pd(T num, char ch = ' '){
   if(num < 0){
     pc('-');
     num = -num;
   }

   char digits[21] = {};
   int pos = 1;

   do{
      digits[pos++] = '0' + num%10;
   }while(num /= 10);

   while(--pos)
      pc(digits[pos]);

   pc(ch);
}

# define sdbl(x)	 scanf("%f", &x)
# define pdbl(x,y)   printf("%.*f ",x,y)
# define pf(x)       printf("%f", x)

// Input int array
template <class T>
inline void iArr(T &arr, int size){
	repf(i, 0, size)
		sd(arr[i]);
}

// Input map input integers
template <class T>
inline int mArr(T &arr, int size){
   int val;
   int mval = INT_MIN;
	repf(i, 0, size)
		sd(val), ++arr[val], mval = max(mval, val);
   return mval;
}

template <class T>
inline void oArr(T &arr, int size){
	repf(i, 0, size)
		pd(arr[i]);
	pnl;
}

template <class T>
inline void iMat(T &mat, int n, int m){
	repf(i, 0, n)
		repf(j, 0, m)
			sd(mat[i][j]);
}

template <class T>
inline void oMat(T &mat, int n, int m){
	repf(i, 0, n){
		repf(j, 0, m)
			pd(mat[i][j]);
		pnl;
	}
}

// character matrix fix :
inline void oMat(char **mat, int n){
	repf(i, 0, n)
	   ps(mat[i]);
}

inline void iMat(char **mat, int n){
	repf(i, 0, n)
		ss(mat[i]);
}

# define lb(x)		lower_bound(x)
# define ub(x)		upper_bound(x)

# define lb(x, y, val)	lower_bound(x, y, val)
# define ub(x, y, val)	upper_bound(x, y, val)

// --------------------------------------------------
// ------------- Data Fillers -----------------------
// --------------------------------------------------

template <class T>
inline void MAT(T **&mat, int n, int m, T val = 0){
   mat = new T*[n];

   if(!val){
    repf(i, 0, n)
      mat[i] = new T[m+1]();
      return ;
   }

   repf(i, 0, n){
      mat[i] = new T[m+1];
      repf(j, 0, m+1)
         mat[i][j] = val;
   }
}

template <class T>
inline void ARR(T *&arr, int n, int val = 0){
   arr = new T[n];
   fill(arr, arr+n, val);
}

// --------------------------------------------------
// ------------ CODE MODES --------------------------
// --------------------------------------------------
# define FAST		ios_base::sync_with_stdio(false); cin.tie(0);
# define TC			int tc; sd(tc); while(tc--)

// --------------------------------------------------
// ----------------- Debugging ----------------------
// --------------------------------------------------
int bug = 0;
# define ok cout<<"OK-"<<bug++<<endl;

// --------------------------------------------------
// ------------- Additional Data --------------------
// --------------------------------------------------

// ---------------------------------------------------------------
// --------------------- Support Codes	---------------------------
// ---------------------------------------------------------------

// ---------------------------------------------------------------
// ------------------------ END	---------------------------------
// ---------------------------------------------------------------

const int MLEN = 1e5+5;

// test should signal true to indicate right movement
ll x, y, p, q;

bool test(ll t){
    return p*t >= x && q*t >= y + (p*t - x);
}

ll bbreak(int l,int r){
	while( r-l > 1 ){
		int mid = l + r >> 1;
		if(test(mid))
			r = mid;
		else
			l = mid;
	}
    return test(r) ? r*q - y : -1;
}

int main(void){

    TC{
        sd(x),sd(y),sd(p),sd(q);
        if(p == 0)
            pd(x ? -1 : 0);
        else
            pd(bbreak(0, 1e9));
    }

    return 0;
}


# include<bits/stdc++.h>

using namespace std;

// Basic
typedef long long 		ll;
typedef long double 		ld;

// Pair
typedef pair<int, int >	   ii;
typedef pair<ll, ll>		   LL;
typedef pair<int, string >	istr;

// List
typedef vector<int >		vi;
typedef vector<vi >		vvi;
typedef vector<ll >		vll;
typedef vector<vll >    vvll;

typedef vector<ii >		vii;
typedef vector<LL >		vLL;

typedef vector<string > vstr;
typedef vector<istr>		vistr;

// Map
typedef map<ll, int > 		mpll;
typedef map<string, int>	mpstr;

// Set
typedef set<string > 		sstr;
typedef set<int >    		si;
typedef set<ii > 				sii;

// multiset
typedef multiset<int >		msi;
typedef multiset<ii >		msii;

// Stacks and Queue
typedef queue<char >       qc;
typedef queue<int >        qi;

typedef stack<char >       stc;
typedef stack<int >        sti;

// ---------------- Value Manipulators --------------------
const int    inf  = 1e9;
const double pi   = acos(-1);
const int    SLMT = 1e5 + 5;
const int    ALMT = 1e6 + 5;

# define ROUND(x)	(int)((double)x + 0.5)

//------------------ REPEAT --------------------------------
# define repf(i, a, b)	for(auto i = a; i != b; ++i)
# define repr(i, a, b)	for(auto i = a; i != b; --i)
# define repstr(i, str)	for(auto i = 0; str[i]; ++i)

// # define uDia(i, j, m, n)	repf(i,0,m) repf(j, i+1, n)
// # define lDia(i, j, m, n)	repf(i,0,m) repf(j,0,i)
// # define cMat(i, j, m, n)	repf(i,0,m)	repf(j,0,n)

// ----------------- STL -----------------------------------
# define mp(x, y)		make_pair(x, y)
# define pb(x) 		    push_back(x)
# define pob()			pop_back()
# define stlf(x)		x.begin(), x.end()
# define stlr(x)		x.rbegin(), x.rend()
# define F				first
# define S				second

// ----------------- I/O -----------------------------------
# define gc()			getchar()
# define pc(x)			putchar(x)

# define ss(str)		scanf("%s", str)
# define ps(str)		puts(str)

# define pnl			pc('\n')

# define sll(x)		sd(x)
# define pll(x)      pd(x)

template <class T >
inline void sd(T &num){

	num = 0;
	int sign = 0;
	char ch;

	while(isspace(ch = gc()));

	if(isdigit(ch))
		num = ch - '0';
	else
		sign = ch == '+' ? 0: 1;

	while(isdigit(ch = gc()))
		num = (num << 3 ) + (num << 1) + ch - '0';

	num = sign ? -num : num;
}

template <class T >
inline void pd(T num, char ch = ' '){
   if(num < 0){
     pc('-');
     num = -num;
   }

   char digits[21] = {};
   int pos = 1;

   do{
      digits[pos++] = '0' + num%10;
   }while(num /= 10);

   while(--pos)
      pc(digits[pos]);

   pc(ch);
}

# define sdbl(x)	 scanf("%f", &x)
# define pdbl(x,y)   printf("%.*f ",x,y)
# define pf(x)       printf("%f", x)

// Input int array
template <class T>
inline void iArr(T &arr, int size){
	repf(i, 0, size)
		sd(arr[i]);
}

// Input map input integers
template <class T>
inline int mArr(T &arr, int size){
   int val;
   int mval = INT_MIN;
	repf(i, 0, size)
		sd(val), ++arr[val], mval = max(mval, val);
   return mval;
}

template <class T>
inline void oArr(T &arr, int size){
	repf(i, 0, size)
		pd(arr[i]);
	pnl;
}

template <class T>
inline void iMat(T &mat, int n, int m){
	repf(i, 0, n)
		repf(j, 0, m)
			sd(mat[i][j]);
}

template <class T>
inline void oMat(T &mat, int n, int m){
	repf(i, 0, n){
		repf(j, 0, m)
			pd(mat[i][j]);
		pnl;
	}
}

// character matrix fix :
inline void oMat(char **mat, int n){
	repf(i, 0, n)
	   ps(mat[i]);
}

inline void iMat(char **mat, int n){
	repf(i, 0, n)
		ss(mat[i]);
}

# define lb(x)		lower_bound(x)
# define ub(x)		upper_bound(x)

# define lb(x, y, val)	lower_bound(x, y, val)
# define ub(x, y, val)	upper_bound(x, y, val)

// --------------------------------------------------
// ------------- Data Fillers -----------------------
// --------------------------------------------------

template <class T>
inline void MAT(T **&mat, int n, int m, T val = 0){
   mat = new T*[n];

   if(!val){
    repf(i, 0, n)
      mat[i] = new T[m+1]();
      return ;
   }

   repf(i, 0, n){
      mat[i] = new T[m+1];
      repf(j, 0, m+1)
         mat[i][j] = val;
   }
}

template <class T>
inline void ARR(T *&arr, int n, int val = 0){
   arr = new T[n];
   fill(arr, arr+n, val);
}

// --------------------------------------------------
// ------------ CODE MODES --------------------------
// --------------------------------------------------
# define FAST		ios_base::sync_with_stdio(false); cin.tie(0);
# define TC			int tc; sd(tc); while(tc--)

// --------------------------------------------------
// ----------------- Debugging ----------------------
// --------------------------------------------------
int bug = 0;
# define ok cout<<"OK-"<<bug++<<endl;

// --------------------------------------------------
// ------------- Additional Data --------------------
// --------------------------------------------------

// ---------------------------------------------------------------
// --------------------- Support Codes	---------------------------
// ---------------------------------------------------------------

// ---------------------------------------------------------------
// ------------------------ END	---------------------------------
// ---------------------------------------------------------------

const int MLEN = 1e5+5;

// test should signal true to indicate right movement
ll x, y, p, q;

bool test(ll t){
    return p*t >= x && q*t - p*t >= y-x;
}

int bbreak(int l,int r){

	while( r-l > 1 ){
		int mid = l + r >> 1;
		if(test(mid))
			r = mid;
		else
			l = mid;
	}
    return test(r) ? r*q - y : -1;
}

int main(void){

    TC{
        sd(x),sd(y),sd(p),sd(q);
        if(p == 0)
            pd(x ? -1 : 0);
        else
            pd(bbreak(0, 1e9));
    }

    return 0;
}


# include<bits/stdc++.h>

using namespace std;

// Basic
typedef long long 		ll;
typedef long double 		ld;

// Pair
typedef pair<int, int >	   ii;
typedef pair<ll, ll>		   LL;
typedef pair<int, string >	istr;

// List
typedef vector<int >		vi;
typedef vector<vi >		vvi;
typedef vector<ll >		vll;
typedef vector<vll >    vvll;

typedef vector<ii >		vii;
typedef vector<LL >		vLL;

typedef vector<string > vstr;
typedef vector<istr>		vistr;

// Map
typedef map<ll, int > 		mpll;
typedef map<string, int>	mpstr;

// Set
typedef set<string > 		sstr;
typedef set<int >    		si;
typedef set<ii > 				sii;

// multiset
typedef multiset<int >		msi;
typedef multiset<ii >		msii;

// Stacks and Queue
typedef queue<char >       qc;
typedef queue<int >        qi;

typedef stack<char >       stc;
typedef stack<int >        sti;

// ---------------- Value Manipulators --------------------
const int    inf  = 1e9;
const double pi   = acos(-1);
const int    SLMT = 1e5 + 5;
const int    ALMT = 1e6 + 5;

# define ROUND(x)	(int)((double)x + 0.5)

//------------------ REPEAT --------------------------------
# define repf(i, a, b)	for(auto i = a; i != b; ++i)
# define repr(i, a, b)	for(auto i = a; i != b; --i)
# define repstr(i, str)	for(auto i = 0; str[i]; ++i)

// # define uDia(i, j, m, n)	repf(i,0,m) repf(j, i+1, n)
// # define lDia(i, j, m, n)	repf(i,0,m) repf(j,0,i)
// # define cMat(i, j, m, n)	repf(i,0,m)	repf(j,0,n)

// ----------------- STL -----------------------------------
# define mp(x, y)		make_pair(x, y)
# define pb(x) 		    push_back(x)
# define pob()			pop_back()
# define stlf(x)		x.begin(), x.end()
# define stlr(x)		x.rbegin(), x.rend()
# define F				first
# define S				second

// ----------------- I/O -----------------------------------
# define gc()			getchar()
# define pc(x)			putchar(x)

# define ss(str)		scanf("%s", str)
# define ps(str)		puts(str)

# define pnl			pc('\n')

# define sll(x)		sd(x)
# define pll(x)      pd(x)

template <class T >
inline void sd(T &num){

	num = 0;
	int sign = 0;
	char ch;

	while(isspace(ch = gc()));

	if(isdigit(ch))
		num = ch - '0';
	else
		sign = ch == '+' ? 0: 1;

	while(isdigit(ch = gc()))
		num = (num << 3 ) + (num << 1) + ch - '0';

	num = sign ? -num : num;
}

template <class T >
inline void pd(T num, char ch = ' '){
   if(num < 0){
     pc('-');
     num = -num;
   }

   char digits[21] = {};
   int pos = 1;

   do{
      digits[pos++] = '0' + num%10;
   }while(num /= 10);

   while(--pos)
      pc(digits[pos]);

   pc(ch);
}

# define sdbl(x)	 scanf("%f", &x)
# define pdbl(x,y)   printf("%.*f ",x,y)
# define pf(x)       printf("%f", x)

// Input int array
template <class T>
inline void iArr(T &arr, int size){
	repf(i, 0, size)
		sd(arr[i]);
}

// Input map input integers
template <class T>
inline int mArr(T &arr, int size){
   int val;
   int mval = INT_MIN;
	repf(i, 0, size)
		sd(val), ++arr[val], mval = max(mval, val);
   return mval;
}

template <class T>
inline void oArr(T &arr, int size){
	repf(i, 0, size)
		pd(arr[i]);
	pnl;
}

template <class T>
inline void iMat(T &mat, int n, int m){
	repf(i, 0, n)
		repf(j, 0, m)
			sd(mat[i][j]);
}

template <class T>
inline void oMat(T &mat, int n, int m){
	repf(i, 0, n){
		repf(j, 0, m)
			pd(mat[i][j]);
		pnl;
	}
}

// character matrix fix :
inline void oMat(char **mat, int n){
	repf(i, 0, n)
	   ps(mat[i]);
}

inline void iMat(char **mat, int n){
	repf(i, 0, n)
		ss(mat[i]);
}

# define lb(x)		lower_bound(x)
# define ub(x)		upper_bound(x)

# define lb(x, y, val)	lower_bound(x, y, val)
# define ub(x, y, val)	upper_bound(x, y, val)

// --------------------------------------------------
// ------------- Data Fillers -----------------------
// --------------------------------------------------

template <class T>
inline void MAT(T **&mat, int n, int m, T val = 0){
   mat = new T*[n];

   if(!val){
    repf(i, 0, n)
      mat[i] = new T[m+1]();
      return ;
   }

   repf(i, 0, n){
      mat[i] = new T[m+1];
      repf(j, 0, m+1)
         mat[i][j] = val;
   }
}

template <class T>
inline void ARR(T *&arr, int n, int val = 0){
   arr = new T[n];
   fill(arr, arr+n, val);
}

// --------------------------------------------------
// ------------ CODE MODES --------------------------
// --------------------------------------------------
# define FAST		ios_base::sync_with_stdio(false); cin.tie(0);
# define TC			int tc; sd(tc); while(tc--)

// --------------------------------------------------
// ----------------- Debugging ----------------------
// --------------------------------------------------
int bug = 0;
# define ok cout<<"OK-"<<bug++<<endl;

// --------------------------------------------------
// ------------- Additional Data --------------------
// --------------------------------------------------

// ---------------------------------------------------------------
// --------------------- Support Codes	---------------------------
// ---------------------------------------------------------------

// ---------------------------------------------------------------
// ------------------------ END	---------------------------------
// ---------------------------------------------------------------

const int MLEN = 1e5+5;

// test should signal true to indicate right movement
ll x, y, p, q;

bool test(ll t){
    return p*t >= x && q*t - p*t >= y-x;
}

ll bbreak(int l,int r){

	while( r-l > 1 ){
		int mid = l + r >> 1;
		if(test(mid))
			r = mid;
		else
			l = mid;
	}
    return test(r) ? r*q - y : -1;
}

int main(void){

    TC{
        sd(x),sd(y),sd(p),sd(q);
        if(p == 0)
            pd(x ? -1 : 0);
        else
            pd(bbreak(0, 1e9));
    }

    return 0;
}


# include<bits/stdc++.h>

using namespace std;

// Basic
typedef long long 		ll;
typedef long double 		ld;

// Pair
typedef pair<int, int >	   ii;
typedef pair<ll, ll>		   LL;
typedef pair<int, string >	istr;

// List
typedef vector<int >		vi;
typedef vector<vi >		vvi;
typedef vector<ll >		vll;
typedef vector<vll >    vvll;

typedef vector<ii >		vii;
typedef vector<LL >		vLL;

typedef vector<string > vstr;
typedef vector<istr>		vistr;

// Map
typedef map<ll, int > 		mpll;
typedef map<string, int>	mpstr;

// Set
typedef set<string > 		sstr;
typedef set<int >    		si;
typedef set<ii > 				sii;

// multiset
typedef multiset<int >		msi;
typedef multiset<ii >		msii;

// Stacks and Queue
typedef queue<char >       qc;
typedef queue<int >        qi;

typedef stack<char >       stc;
typedef stack<int >        sti;

// ---------------- Value Manipulators --------------------
const int    inf  = 1e9;
const double pi   = acos(-1);
const int    SLMT = 1e5 + 5;
const int    ALMT = 1e6 + 5;

# define ROUND(x)	(int)((double)x + 0.5)

//------------------ REPEAT --------------------------------
# define repf(i, a, b)	for(auto i = a; i != b; ++i)
# define repr(i, a, b)	for(auto i = a; i != b; --i)
# define repstr(i, str)	for(auto i = 0; str[i]; ++i)

// # define uDia(i, j, m, n)	repf(i,0,m) repf(j, i+1, n)
// # define lDia(i, j, m, n)	repf(i,0,m) repf(j,0,i)
// # define cMat(i, j, m, n)	repf(i,0,m)	repf(j,0,n)

// ----------------- STL -----------------------------------
# define mp(x, y)		make_pair(x, y)
# define pb(x) 		    push_back(x)
# define pob()			pop_back()
# define stlf(x)		x.begin(), x.end()
# define stlr(x)		x.rbegin(), x.rend()
# define F				first
# define S				second

// ----------------- I/O -----------------------------------
# define gc()			getchar()
# define pc(x)			putchar(x)

# define ss(str)		scanf("%s", str)
# define ps(str)		puts(str)

# define pnl			pc('\n')

# define sll(x)		sd(x)
# define pll(x)      pd(x)

template <class T >
inline void sd(T &num){

	num = 0;
	int sign = 0;
	char ch;

	while(isspace(ch = gc()));

	if(isdigit(ch))
		num = ch - '0';
	else
		sign = ch == '+' ? 0: 1;

	while(isdigit(ch = gc()))
		num = (num << 3 ) + (num << 1) + ch - '0';

	num = sign ? -num : num;
}

template <class T >
inline void pd(T num, char ch = ' '){
   if(num < 0){
     pc('-');
     num = -num;
   }

   char digits[21] = {};
   int pos = 1;

   do{
      digits[pos++] = '0' + num%10;
   }while(num /= 10);

   while(--pos)
      pc(digits[pos]);

   pc(ch);
}

# define sdbl(x)	 scanf("%f", &x)
# define pdbl(x,y)   printf("%.*f ",x,y)
# define pf(x)       printf("%f", x)

// Input int array
template <class T>
inline void iArr(T &arr, int size){
	repf(i, 0, size)
		sd(arr[i]);
}

// Input map input integers
template <class T>
inline int mArr(T &arr, int size){
   int val;
   int mval = INT_MIN;
	repf(i, 0, size)
		sd(val), ++arr[val], mval = max(mval, val);
   return mval;
}

template <class T>
inline void oArr(T &arr, int size){
	repf(i, 0, size)
		pd(arr[i]);
	pnl;
}

template <class T>
inline void iMat(T &mat, int n, int m){
	repf(i, 0, n)
		repf(j, 0, m)
			sd(mat[i][j]);
}

template <class T>
inline void oMat(T &mat, int n, int m){
	repf(i, 0, n){
		repf(j, 0, m)
			pd(mat[i][j]);
		pnl;
	}
}

// character matrix fix :
inline void oMat(char **mat, int n){
	repf(i, 0, n)
	   ps(mat[i]);
}

inline void iMat(char **mat, int n){
	repf(i, 0, n)
		ss(mat[i]);
}

# define lb(x)		lower_bound(x)
# define ub(x)		upper_bound(x)

# define lb(x, y, val)	lower_bound(x, y, val)
# define ub(x, y, val)	upper_bound(x, y, val)

// --------------------------------------------------
// ------------- Data Fillers -----------------------
// --------------------------------------------------

template <class T>
inline void MAT(T **&mat, int n, int m, T val = 0){
   mat = new T*[n];

   if(!val){
    repf(i, 0, n)
      mat[i] = new T[m+1]();
      return ;
   }

   repf(i, 0, n){
      mat[i] = new T[m+1];
      repf(j, 0, m+1)
         mat[i][j] = val;
   }
}

template <class T>
inline void ARR(T *&arr, int n, int val = 0){
   arr = new T[n];
   fill(arr, arr+n, val);
}

// --------------------------------------------------
// ------------ CODE MODES --------------------------
// --------------------------------------------------
# define FAST		ios_base::sync_with_stdio(false); cin.tie(0);
# define TC			int tc; sd(tc); while(tc--)

// --------------------------------------------------
// ----------------- Debugging ----------------------
// --------------------------------------------------
int bug = 0;
# define ok cout<<"OK-"<<bug++<<endl;

// --------------------------------------------------
// ------------- Additional Data --------------------
// --------------------------------------------------

// ---------------------------------------------------------------
// --------------------- Support Codes	---------------------------
// ---------------------------------------------------------------

// ---------------------------------------------------------------
// ------------------------ END	---------------------------------
// ---------------------------------------------------------------

const int MLEN = 1e5+5;

// test should signal true to indicate right movement
ll x, y, p, q;

bool test(int t){
    return p*t >= x && q*t - p*t >= y-x;
}

int bbreak(int l,int r){

	while( r-l > 1 ){
		int mid = l + r >> 1;
		if(test(mid))
			r = mid;
		else
			l = mid;
	}
    return test(r) ? r*q - y : -1;
}

int main(void){

    TC{
        sd(x),sd(y),sd(p),sd(q);
        if(p == 0)
            pd(x ? -1 : 0,'\n');
        else
            pd(bbreak(0, 1e9),'\n');
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		search();
		output();
	}

private:
	long long num;
	long long  **arr;
	long long *result;

	void input()
	{
		cin>>num;
		arr=new long long *[num];
		for(long long i=0;i<num;i++)
		{
			arr[i]=new long long[4];
			for(long long j=0;j<4;j++) cin>>arr[i][j];
		}
		result=new long long [num];
	}

	void search()
	{
		for(long long i=0;i<num;i++) result[i]=subb(arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
	}

	long long subb(long long x,long long y,long long p,long long q)
	{
		long long a=0,z=1000000000,mid=z/2;
		for(;;)
		{
			long long temp=smallest(x,y,p,q,mid);

			if(temp==0) return (mid*q-y);
			else if(temp==1)  {z=mid; mid=(a+z)/2;}
			else if(temp==-1) {a=mid; mid=(a+z)/2;}

			if(mid==a) break;
		}
		return -1;
	}

	long long smallest(long long x,long long y,long long p,long long q,long long mid)
	{
		long long A=(mid*p),B=(mid*q);
		long long a=((mid-1)*p),b=((mid-1)*q);

		if((B>=y) && (A>=x) && ((B-y)>=(A-x)))
		{
			if((b>=y) && (a>=x) && ((b-y)>=(a-x))) return 1;
			else return 0;
		}

		else return -1;
	}

	void output()
	{
		for(long long i=0;i<num;i++) cout<<result[i]<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		search();
		output();
	}

private:
	long long num;
	long long  **arr;
	long long *result;

	void input()
	{
		cin>>num;
		arr=new long long *[num];
		for(long long i=0;i<num;i++)
		{
			arr[i]=new long long[4];
			for(long long j=0;j<4;j++) cin>>arr[i][j];
		}
		result=new long long [num];
	}

	void search()
	{
		for(long long i=0;i<num;i++) result[i]=subb(arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
	}

	long long subb(long long x,long long y,long long p,long long q)
	{
		long long a=0,z=2000000000,mid=z/2;
		for(;;)
		{
			long long temp=smallest(x,y,p,q,mid);

			if(temp==0) return (mid*q-y);
			else if(temp==1)  {z=mid; mid=(a+z)/2;}
			else if(temp==-1) {a=mid; mid=(a+z)/2;}

			if(mid==a) break;
		}
		return -1;
	}

	long long smallest(long long x,long long y,long long p,long long q,long long mid)
	{
		long long A=(mid*p),B=(mid*q);
		long long a=((mid-1)*p),b=((mid-1)*q);

		if((B>=y) && (A>=x) && ((B-y)>=(A-x)))
		{
			if((b>=y) && (a>=x) && ((b-y)>=(a-x))) return 1;
			else return 0;
		}

		else return -1;
	}

	void output()
	{
		for(long long i=0;i<num;i++) cout<<result[i]<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include<iostream>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		search();
		output();
	}

private:
	long long num;
	long long  **arr;
	long long *result;

	void input()
	{
		cin>>num;
		arr=new long long *[num];
		for(int i=0;i<num;i++)
		{
			arr[i]=new long long[4];
			for(int j=0;j<4;j++) cin>>arr[i][j];
		}
		result=new long long [num];
	}

	void search()
	{
		for(int i=0;i<num;i++) result[i]=subb(arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
	}

	long long subb(long long x,long long y,long long p,long long q)
	{
		int a=1,z=1000000000,mid=z/2;
		for(;;)
		{
			long long temp=smallest(x,y,p,q,mid);

			if(temp==0) return (mid*q-y);
			else if(temp==1)  {z=mid; mid=(a+z)/2;}
			else if(temp==-1) {a=mid; mid=(a+z)/2;}

			if(mid==a) break;
		}
		return -1;
	}

	long long smallest(long long x,long long y,long long p,long long q,long long mid)
	{
		long long A=(mid*p),B=(mid*q);
		long long a=((mid-1)*p),b=((mid-1)*q);

		if((B>=y) && (A>=x) && ((B-y)>=(A-x)))
		{
			if((b>=y) && (a>=x) && ((b-y)>=(a-x))) return 1;
			else return 0;
		}

		else return -1;
	}

	void output()
	{
		for(int i=0;i<num;i++) cout<<result[i]<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include<iostream>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		search();
		output();
	}

private:
	long long num;
	long long  **arr;
	long long *result;

	void input()
	{
		cin>>num;
		arr=new long long *[num];
		for(long long i=0;i<num;i++)
		{
			arr[i]=new long long[4];
			for(long long j=0;j<4;j++) cin>>arr[i][j];
		}
		result=new long long [num];
	}

	void search()
	{
		for(long long i=0;i<num;i++) result[i]=subb(arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
	}

	long long subb(long long x,long long y,long long p,long long q)
	{
		long long a=0,z=2000000000,mid=z/2;
		for(;;)
		{
			long long temp=smallest(x,y,p,q,mid);

			if(temp==0) return (mid*q-y);
			else if(temp==1)  {z=mid; mid=(a+z)/2;}
			else if(temp==-1) {a=mid; mid=(a+z)/2;}

			if(mid==a) break;
		}
		return -1;
	}

	long long smallest(long long x,long long y,long long p,long long q,long long mid)
	{
		long long A=(mid*p),B=(mid*q);
		long long a=((mid-1)*p),b=((mid-1)*q);

		if((B>=y) && (A>=x) && ((B-y)>=(A-x)))
		{
			if((b>=y) && (a>=x) && ((b-y)>=(a-x))) return 1;
			else return 0;
		}

		else return -1;
	}

	void output()
	{
		for(long long i=0;i<num;i++) cout<<result[i]<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}