import math

a, b=map(int, input().split())
n=int(input())
l=[]
d=math.gcd(a,b)
for i in range(1, int(d**(1/2)+1)):
    if d%i==0:
        l.append(i)
        if i*i!=d:
            l.append(d//i)
for j in range(n):
    m=[]
    x, y=map(int, input().split())
    r=-1
    for k in l:
        if k>=x and k<=y:
            r=max(r,k)
    print(r)


import math

a, b=map(int, input().split())
n=int(input())
l=[]
d=math.gcd(a,b)
for i in range(1, d+1):
    if d%i==0:
        l.append(i)
for j in range(n):
    m=[]
    x, y=map(int, input().split())
    r=-1
    for k in l:
        if k>=x and k<=y:
            r=max(r,k)
    print(r)


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <complex>
#include <string>
using namespace std;

int n, a, b;

int myabs(int x){
    if (x<0) return -x;
    return x;
}

int main(){
    scanf("%d%d%d",&a,&b,&n);
    if (b==0) printf("1");
    else if (b%a!=0){
        printf("No solution");
    }else{
        b/=a;
        if (b<0 && n%2==0) printf("No solution");
        else{
            int r, re=0;
            for (r = 0; re<myabs(b); r++){
                re=1;
                for (int i=0; i<n; i++) re*=r;
            }
            r--;
            if (re!=myabs(b)) printf("No solution");
            else if (b>0) printf("%d",(int)r);
            else printf("-%d",(int)r);
        }
    }
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <complex>
#include <string>
using namespace std;

int n, a, b;

int myabs(int x){
    if (x<0) return -x;
    return x;
}

int main(){
    scanf("%d%d%d",&a,&b,&n);
    if (a==0)
        if (b==0) printf("1");
        else printf("No solution");
    else if (b%a!=0){
        printf("No solution");
    }else{
        b/=a;
        if (b<0 && n%2==0) printf("No solution");
        else{
            int r, re=0;
            for (r = 0; re<myabs(b); r++){
                re=1;
                for (int i=0; i<n; i++) re*=r;
            }
            r--;
            if (re!=myabs(b)) printf("No solution");
            else if (b>0) printf("%d",(int)r);
            else printf("-%d",(int)r);
        }
    }
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <complex>
#include <string>
using namespace std;

int n, a, b;

int main(){
    scanf("%d%d%d",&a,&b,&n);
    if (b==0) printf("1");
    else if (b%a!=0){
        printf("No solution");
    }else{
        b/=a;
        if (b<0 && n%2==0) printf("No solution");
        else{
            double r = pow(abs(b),1.0/n);
            int rr = (int)r;
            for (int i=1; i<n; i++) rr*=(int)r;
            //printf("%d\n",rr);
            if (rr!=abs(b)) printf("No solution");
            else if (b>0) printf("%d",(int)r);
            else printf("-%d",(int)r);
        }
    }
}


//Sandro Mirianashvili
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <cstring>

#define ll long long
#define l long
#define ull unsigned ll
#define pb push_back
#define in insert
#define FORI(N)for(int i = 1 ; i <= N ; i++)
#define FORJ(N)for(int j = 0 ; j < N ; j++)
#define PI acos(-1)
#define fi first
#define se second
#define MAX(a,b)(a > b)?(a):(b)
#define MIN(a,b)(a > b)?(b):(a)
#define MOD 10
#define NMAX 50000

using namespace std;

int a , b , N;

int main()
{
 // freopen("INPUT.TXT","r",stdin);
  //freopen("OUTPUT.TXT","w",stdout);
  cin >> a >> b >> N;
  for(int i = (-999) ; i < 999 ; i++){
     if(a * (int)(pow(i,N)) == b){
       cout << i << endl;
       return 0;
     }
  }
  cout << "No solution" << endl;
  return 0;
}


//Sandro Mirianashvili
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <cstring>

#define ll long long
#define l long
#define ull unsigned ll
#define pb push_back
#define in insert
#define FORI(N)for(int i = 1 ; i <= N ; i++)
#define FORJ(N)for(int j = 0 ; j < N ; j++)
#define PI acos(-1)
#define fi first
#define se second
#define MAX(a,b)(a > b)?(a):(b)
#define MIN(a,b)(a > b)?(b):(a)
#define MOD 10
#define NMAX 50000

using namespace std;

int a , b , N;

int main()
{
 // freopen("INPUT.TXT","r",stdin);
  //freopen("OUTPUT.TXT","w",stdout);
  cin >> a >> b >> N;
  for(int i = (-10000) ; i < 10000 ; i++){
     if(a * (int)(pow(i,N)) == b){
       cout << i << endl;
       return 0;
     }
  }
  cout << "No solution" << endl;
  return 0;
}


//Sandro Mirianashvili
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <cstring>

#define ll long long
#define l long
#define ull unsigned ll
#define pb push_back
#define in insert
#define FORI(N)for(int i = 1 ; i <= N ; i++)
#define FORJ(N)for(int j = 0 ; j < N ; j++)
#define PI acos(-1)
#define fi first
#define se second
#define MAX(a,b)(a > b)?(a):(b)
#define MIN(a,b)(a > b)?(b):(a)
#define MOD 10
#define NMAX 50000

using namespace std;

ll a , b , N;

int main()
{
 // freopen("INPUT.TXT","r",stdin);
  //freopen("OUTPUT.TXT","w",stdout);
  cin >> a >> b >> N;
  if(b == 0){
       cout << 0 << endl;
       return 0;
       }
  for(int i = (-999) ; i <= 1000 ; i++){
     if(a * (int)(pow(i,N)) == b){
       cout << i << endl;
       return 0;
     }
  }
  cout << "No solution" << endl;
  return 0;
}


//Sandro Mirianashvili
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <cstring>

#define ll long long
#define l long
#define ull unsigned ll
#define pb push_back
#define in insert
#define FORI(N)for(int i = 1 ; i <= N ; i++)
#define FORJ(N)for(int j = 0 ; j < N ; j++)
#define PI acos(-1)
#define fi first
#define se second
#define MAX(a,b)(a > b)?(a):(b)
#define MIN(a,b)(a > b)?(b):(a)
#define MOD 10
#define NMAX 50000

using namespace std;

int a , b , N;

int main()
{
 // freopen("INPUT.TXT","r",stdin);
  //freopen("OUTPUT.TXT","w",stdout);
  cin >> a >> b >> N;
  if(b == 0){
       cout << 0 << endl;
       return 0;
       }
  for(int i = (-999) ; i <= 1000 ; i++){
     if(a * (int)(pow(i,N)) == b){
       cout << i << endl;
       return 0;
     }
  }
  cout << "No solution" << endl;
  return 0;
}


//Sandro Mirianashvili
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <cstring>

#define ll long long
#define l long
#define ull unsigned ll
#define pb push_back
#define in insert
#define FORI(N)for(int i = 1 ; i <= N ; i++)
#define FORJ(N)for(int j = 0 ; j < N ; j++)
#define PI acos(-1)
#define fi first
#define se second
#define MAX(a,b)(a > b)?(a):(b)
#define MIN(a,b)(a > b)?(b):(a)
#define MOD 10
#define NMAX 50000

using namespace std;

int a , b , N , x;

int main()
{
  //freopen("INPUT.TXT","r",stdin);
  //freopen("OUTPUT.TXT","w",stdout);
  cin >> a >> b >> N;
  for(int i = -10000 ; i <= 10000 ; i++){
    x = i;
    for(int j = 1 ; (j < N)  && (x < 10000) ; j++) x *= i;
    if(a * x == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << "No solution" << endl;
  return 0;
}


//Sandro Mirianashvili
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <cstring>

#define ll long long
#define l long
#define ull unsigned ll
#define pb push_back
#define in insert
#define FORI(N)for(int i = 1 ; i <= N ; i++)
#define FORJ(N)for(int j = 0 ; j < N ; j++)
#define PI acos(-1)
#define fi first
#define se second
#define MAX(a,b)(a > b)?(a):(b)
#define MIN(a,b)(a > b)?(b):(a)
#define MOD 10
#define NMAX 50000

using namespace std;

int a , b , N;

int main()
{
 // freopen("INPUT.TXT","r",stdin);
  //freopen("OUTPUT.TXT","w",stdout);
  cin >> a >> b >> N;
  for(int i = (-999) ; i <= 1000 ; i++){
     if(a * (int)(pow(i,N)) == b){
       cout << i << endl;
       return 0;
     }
  }
  cout << "No solution" << endl;
  return 0;
}


#include<iostream>

using namespace std;

int main()
{
	int a , b , n;
	cin>> a >> b >> n;
	if(b==0)
	{
		cout<< 0 << endl;
		return 0;
	}
	if(a==0)
	{
		cout<<"No solution" << endl;
		return 0;
	}
	b/=a;
	int i=0;
	int res=1;
	if(res == b)
	{
		cout<< 1 << endl;
		return 0;
	}
	while(res < b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		//cout<< "res " << res << endl;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i++;
	}
	i=-1;
	while(res > b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		//cout<< "res : " << res << endl;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i--;
	}
	cout<< "No solution" << endl;
}


#include<iostream>

using namespace std;

int f(int a, int b)
{
	int p=1;
	for(int i=1 ; i<=b ; i++)
		p=p*a;
	return p;
}

int main()
{
	int a , b, n;
	cin>>a >> b >> n;
	if(b==0)
	{
		cout<< 0 << endl;
		return 0;
	}
	if(a==0)
	{
		if(b==0)
			cout<< 5 << endl;
		else
			cout<< "No solution" << endl;
		return 0;
	}
	b/=a;
	for(int i=1000 ; i>=-1000  ; i--)
	{
		int q=f(i , n);
		if(q==b)
		{
			cout<< i << endl;
			return 0;
		}
	}
	cout<< "No solution" << endl;
}


#include<iostream>

using namespace std;

int main()
{
	int a , b , n;
	cin>> a >> b >> n;
	if(b==0)
	{
		cout<< 0 << endl;
		return 0;
	}
	if(a==0)
	{
		cout<<"No solution" << endl;
		return 0;
	}
	b/=a;
	int i=0;
	int res=1;
	while(res < b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i++;
	}
	i=-1;
	while(res > b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		// cout<< "res : " << res << endl;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i--;
	}
	cout<< "No solution" << endl;
}


#include<iostream>

using namespace std;

int main()
{
	int a , b , n;
	cin>> a >> b >> n;
	if(b==0)
	{
		cout<< 0 << endl;
		return 0;
	}
	if(a==0)
	{
		cout<<"No solution" << endl;
		return 0;
	}
	b/=a;
	int i=0;
	int res=1;
	if(res == b)
	{
		cout<< 1 << endl;
		return 0;
	}
	while(res < b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		cout<< "res " << res << endl;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i++;
	}
	i=-1;
	while(res > b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		cout<< "res : " << res << endl;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i--;
	}
	cout<< "No solution" << endl;
}


#include<iostream>

using namespace std;

int main()
{
	int a , b , n;
	cin>> a >> b >> n;
	b/=a;
	int i=0;
	int res=1;
	while(res < b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i++;
	}
	i=-1;
	while(res > b)
	{
		res=1;
		for(int j=0 ; j<n ; j++)
			res*=i;
		// cout<< "res : " << res << endl;
		if(res==b)
		{
			cout<< i << endl;
			return 0;
		}
		i--;
	}
	cout<< "No solution" << endl;
}


#include<iostream>

using namespace std;

int f(int a, int b)
{
	int p=1;
	for(int i=1 ; i<=b ; i++)
		p=p*a;
	return p;
}

int main()
{
	int a , b, n;
	cin>>a >> b >> n;
	if(a==0)
	{
		if(b==0)
			cout<< 5 << endl;
		else
			cout<< "No solution" << endl;
		return 0;
	}
	b/=a;
	for(int i=1000 ; i>=-1000  ; i--)
	{
		int q=f(i , n);
		if(q==b)
		{
			cout<< i << endl;
			return 0;
		}
	}
	cout<< "No solution" << endl;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        float A, B, n, X;

    cin >> A >> B >> n;

    for(X = 1005; X > -1005; X --)
        if((A * pow(X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

/*
        float p1, p2, p3;
        int aux;
    p1 = pow(abs(A), (1.0/n));
    p2 = pow(abs(B), (1.0/n));
    p3 = p2 / p1;
    if(A < 0 || B < 0) p3 *= -1;
    aux = (int) p3;
    if(!(p3 - aux))
        cout << p3 << endl;
    else
        cout << "No solution" << endl;
*/
    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, R;
    cin >> A >> B >> n;
    for(int X = -1000; X <= 1000; X ++)
        if(fabs(A * pow((double)X, (double)n) - B) < 1e-9){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;
    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, X;

    cin >> A >> B >> n;

    for(int X = 1005; X > -1005; X --)
        if((A * pow(X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

/*
        float p1, p2, p3;
        int aux;
    p1 = pow(abs(A), (1.0/n));
    p2 = pow(abs(B), (1.0/n));
    p3 = p2 / p1;
    if(A < 0 || B < 0) p3 *= -1;
    aux = (int) p3;
    if(!(p3 - aux))
        cout << p3 << endl;
    else
        cout << "No solution" << endl;
*/
    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, X;

    cin >> A >> B >> n;

    for(X = 1005; X > -1005; X --)
        if((A * pow((double)X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, R1, R2;

    cin >> A >> B >> n;

    for(int X1 = 0, X2 = 0; X1 <= 1000 && X2 >= -1000; X1 ++, X2 --){
        R1 = (int) pow((double)X1, n);
        R1 *= A;
        if(R1 == B){
            cout << X1 << endl;
            return 0;
        }
        R2 = (int) pow((double)X2, n);
        R2 *= A;
        if(R2 == B){
            cout << X2 << endl;
            return 0;
        }
    }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        long long int A, B, n, X, R;

    cin >> A >> B >> n;

    for(X = 1005; X > -1005; X --){
        R = A * pow(X,n);
        if(R == B){
            cout << X << endl;
            return 0;
        }
    }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        long long int A, B, n, X;

    cin >> A >> B >> n;

    for(X = 1005; X > -1005; X --)
        if((A * pow((double)X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, R;
    cin >> A >> B >> n;
    for(int X = -1000; X <= 1000; X ++)
        if(fabs(A * pow((double)X, (double)n) - B) < 1e-9){
            cout << X << endl;
            break;
        }
    cout << "No solution" << endl;
    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        long long int A, B, n, X;

    cin >> A >> B >> n;

    if(A == 1 && n == 1){
        cout << B << endl;
        return 0;
    }

    for(X = 1005; X > -1005; X --)
        if((A * pow(X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, X;

    cin >> A >> B >> n;

    for(X = 1005; X > -1005; X --)
        if((A * pow(X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

/*
        float p1, p2, p3;
        int aux;
    p1 = pow(abs(A), (1.0/n));
    p2 = pow(abs(B), (1.0/n));
    p3 = p2 / p1;
    if(A < 0 || B < 0) p3 *= -1;
    aux = (int) p3;
    if(!(p3 - aux))
        cout << p3 << endl;
    else
        cout << "No solution" << endl;
*/
    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, R1, R2;

    cin >> A >> B >> n;

    for(int X = 0; X >= -1000; X --){
        R1 = (int) pow((double)X, n);
        R1 *= A;
        if(R1 == B){
            cout << X << endl;
            return 0;
        }
        R2 = (int) pow((double)abs(X), n);
        R2 *= A;
        if(R2 == B){
            cout << abs(X) << endl;
            return 0;
        }
    }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, R;

    cin >> A >> B >> n;

    for(int X = -1000; X <= 1000; X ++){
        R = (int) pow((double)X, n);
        R *= A;
        if(R == B){
            cout << X << endl;
            return 0;
        }
    }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n;

    cin >> A >> B >> n;

    for(int X = 1005; X > -1005; X --)
        if((A * pow((double)X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        long long int A, B, n, X;

    cin >> A >> B >> n;

    if(n == 1){
        for(X = 1005; X > -1005; X --)
            if((A * X) == B){
                cout << X << endl;
                return 0;
            }
    }
    else{
        for(X = 1005; X > -1005; X --)
            if((A * pow(X,n)) == B){
                cout << X << endl;
                return 0;
            }
    }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n;

    cin >> A >> B >> n;

    for(int X = -1000; X <= 1000; X ++)
        if((A * pow((double)X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        int A, B, n, X;

    cin >> A >> B >> n;

    if(A == 1 && n == 1){
        cout << B << endl;
        return 0;
    }

    for(X = 1005; X > -1005; X --)
        if((A * pow(X,n)) == B){
            cout << X << endl;
            return 0;
        }
    cout << "No solution" << endl;

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
        float A, B, n, X;
        float p1, p2, p3;
        int aux;

    cin >> A >> B >> n;

    p1 = pow(abs(A), (1.0/n));
    p2 = pow(abs(B), (1.0/n));

    p3 = p2 / p1;
    if(A < 0 || B < 0) p3 *= -1;

    aux = (int) p3;
    if(!(p3 - aux))
        cout << p3 << endl;
    else
        cout << "No solution" << endl;

    return 0;
}


#include<cstdio>
#define For(i,__,___) for(int i=__;i<=___;i++)
int pow(int a,int b)
{
    int res=1;
    for(;b;b>>=1,a*=a)if(b&1)res*=a;
    return res;
}
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	For(x,-1000,1000)if(a*pow(x,n)==b)return printf("%d\n",x),0;
	puts("No solution");
}


#include<cstdio>
#include<cmath>
#define For(i,__,___) for(int i=__;i<=___;i++)
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	For(x,-1000,1000)if((int)(a*pow(x,n)+0.5)==b)return printf("%d\n",x),0;
	puts("No solution");
}


#include<cstdio>
#include<cmath>
#define For(i,__,___) for(int i=__;i<=___;i++)
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	For(x,-1000,1000)if((int)(a*pow(x,n))==b)return printf("%d\n",x),0;
	puts("No solution");
}


#include<cstdio>
#include<cmath>
#define For(i,__,___) for(int i=__;i<=___;i++)
int a,b,n;
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	For(x,-1000,1000)if(a*pow(x,n)==b)return printf("%d\n",x),0;
	puts("No solution");
}


#include<cstdio>
#include<cmath>
#define For(i,__,___) for(int i=__;i<=___;i++)
int a,b,n;
int calc(int x)
{
    double res=a*pow(x,n);
    if(res>0)return res+0.5;
    if(res<0)return res-0.5;
    return res;
}
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	For(x,-1000,1000)if(calc(x)==b)return printf("%d\n",x),0;
	puts("No solution");
}


#include<cstdio>
#include<cmath>
#define For(i,__,___) for(int i=__;i<=___;i++)
int a,b,n;
int calc(int x)
{
    double res=a*pow(x,n);
    if(res>0)return res+0.5;
    if(res<0)return res-0.5;
}
int main()
{
	scanf("%d%d%d",&a,&b,&n);
	For(x,-1000,1000)if(calc(x)==b)return printf("%d\n",x),0;
	puts("No solution");
}


//In The Name Of God
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int a , b , n ;
int main ( )
{
  cin >> a >> b >> n ;
  if ( a == 0 )
    {
      if ( b == 0 )
	{
	cout << 0 ;
	exit ( 0 ) ;
	}
	cout << "No solution" ;
	exit ( 0 ) ;
    }
  for ( int i = 0 ; i <= 10000 ; i ++ )
    if ( int ( pow ( i , n ) ) == b / a )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( int ( pow ( i , n ) ) == b / a )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  //gfdpagfjg.
  cout << "No solution" ;
}


//In The Name Of God
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int a , b , n ;
int main ( )
{
  cin >> a >> b >> n ;
  for ( int i = 0 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  cout << "No solution" ;
}


//In The Name Of God
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int a , b , n ;
int main ( )
{
  cin >> a >> b >> n ;
  for ( int i = 0 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  //gfdpagfjg
  cout << "No solution" ;
}


//In The Name Of God
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int a , b , n ;
int main ( )
{
  cin >> a >> b >> n ;
if ( n == 1 )
{
cout <<  b / a ;
exit ( 0 ) ;
}
  for ( int i = 0 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  //gfdpagfjg.
  cout << "No solution" ;
}


// In The Name Of God :
#include <bits/stdc++.h>
using namespace std ;
#define PB push_back
#define X first
#define Y second
#define S string
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<<"";
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define make_it(h) set<int>::iterator h ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
//#define cout<< cout<<setprecision ( 25 )<<;
typedef long long ll;
typedef long double ld;
typedef pair < int , int > pii ;
typedef pair < int , pii > piii ;
const int maxn = 1e5 + 100  ;
const int b_n = 1e18 + 1  ;
const ld pi = 3.14 ;
const int mod = 1e9 + 7 ;
const int base = 173 ;
int ans ;
ld a , b , n ;

int pown ( int x , int y )
{
  if ( y == 0 )
    return 1 ;
  int ret = pown ( x , y / 2 ) ;
  ret *= ret ;
  if ( y & 1 )
    ret *= x ;
  return ret ;
}

main ( )
{
  cin >> a >> b >> n ;
  if ( a == 0 )
    {
      if ( b == 0 )
	{
	cout << 0 ;
	exit ( 0 ) ;
	}
	cout << "No solution" ;
	exit ( 0 ) ;
    }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( ld ( pown ( i , n ) ) == b / a )
      if ( abs ( ans ) > abs ( i ) )
	ans = i ;
  if ( ld ( pown ( ans , n ) ) == b / a )
    cout << ans ;
  else
    cout << "No solution" ;
}


//In The Name Of God
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int a , b , n ;
int main ( )
{
  cin >> a >> b >> n ;
if ( n == 1 )
{
cout <<  b ;
exit ( 0 ) ;
}
  for ( int i = 0 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  //gfdpagfjg.
  cout << "No solution" ;
}


//In The Name Of God
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int a , b , n ;
int main ( )
{
  cin >> a >> b >> n ;
  if ( a == 0 )
    {
      if ( b == 0 )
	cout << 0 ;
      cout << "No solution" ;
    }
  for ( int i = 0 ; i <= 10000 ; i ++ )
    if ( int ( pow ( i , n ) ) == b / a )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( int ( pow ( i , n ) ) == b / a )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  //gfdpagfjg.
  cout << "No solution" ;
}


// In The Name Of God :
#include <bits/stdc++.h>
using namespace std ;
#define PB push_back
#define X first
#define Y second
#define S string
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<<"";
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define make_it(h) set<int>::iterator h ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
//#define cout<< cout<<setprecision ( 25 )<<;
typedef long long ll;
typedef long double ld;
typedef pair < int , int > pii ;
typedef pair < int , pii > piii ;
const int maxn = 1e5 + 100  ;
const int b_n = 1e18 + 1  ;
const ld pi = 3.14 ;
const int mod = 1e9 + 7 ;
const int base = 173 ;
ld a , b , n ;

int pown ( int x , int y )
{
  if ( y == 0 )
    return 1 ;
  int ret = pown ( x , y / 2 ) ;
  ret *= ret ;
  if ( y & 1 )
    ret *= x ;
  return ret ;
}

main ( )
{
  cin >> a >> b >> n ;
  if ( a == 0 )
    {
      if ( b == 0 )
	{
	cout << 0 ;
	exit ( 0 ) ;
	}
	cout << "No solution" ;
	exit ( 0 ) ;
    }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( ld ( pown ( i , n ) ) == b / a )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  cout << "No solution" ;
}


//In The Name Of God
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int a , b , n ;
int main ( )
{
  cin >> a >> b >> n ;
  for ( int i = 0 ; i < 1000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  for ( int i = -1000 ; i < 1000 ; i ++ )
    if ( a * pow ( i , n ) == b )
      {
	cout << i ;
	exit ( 0 ) ;
      }
  cout << "No solution" ;
}


// In The Name Of God :
#include <bits/stdc++.h>
using namespace std ;
#define PB push_back
#define X first
#define Y second
#define S string
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<<"";
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define make_it(h) set<int>::iterator h ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
//#define cout<< cout<<setprecision ( 25 )<<;
typedef long long ll;
typedef long double ld;
typedef pair < int , int > pii ;
typedef pair < int , pii > piii ;
const int maxn = 1e5 + 100  ;
const int b_n = 1e18 + 1  ;
const ld pi = 3.14 ;
const int mod = 1e9 + 7 ;
const int base = 173 ;
int ans ;
ld a , b , n ;

int pown ( int x , int y )
{
  if ( y == 0 )
    return 1 ;
  int ret = pown ( x , y / 2 ) ;
  ret *= ret ;
  if ( y & 1 )
    ret *= x ;
  return ret ;
}

main ( )
{
  ans = - 1e4 ;
  cin >> a >> b >> n ;
  if ( a == 0 )
    {
      if ( b == 0 )
	{
	cout << 0 ;
	exit ( 0 ) ;
	}
	cout << "No solution" ;
	exit ( 0 ) ;
    }
  for ( int i = -10000 ; i <= 10000 ; i ++ )
    if ( ld ( pown ( i , n ) ) == b / a )
      if ( abs ( ans ) > abs ( i ) )
	ans = i ;
  if ( ld ( pown ( ans , n ) ) * a == b )
    cout << ans ;
  else
    cout << "No solution" ;
}


#include <cstdio>
#include <math.h>
int pow(int a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
	if (a == 0 && b != 0 || a != 0 && b == 0) {
		printf("No solution");
		return 0;
	} else if (a == 0 && b == 0) {
		printf("0");
		return 0;
	}
	int t = b / a, y = fabs(t);
	int l = -1, r = 10000, m;
	while (l < r - 1) {
		m = (l + r) / 2;
		if (pow(m, n) >= y)
			r = m;
		else
			l = m;
	}
	int otv1 = pow(r, n), otv2 = pow(-r, n);
	if (n % 2 == 0 && t < 0 ||  otv1 != t &&  otv2 != t)
		printf("No solution");
	else if (otv2 == t)
		printf("%d\n", -r);
	else
		printf("%d", r);

	return 0;
}


#include <cstdio>
#include <math.h>
long long pow(long long a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
	if (a == 0 && b != 0 || a != 0 && b == 0) {
		printf("No solution");
		return 0;
	} else if (a == 0 && b == 0) {
		printf("0");
		return 0;
	}
	int t = b / a, y = fabs(t);
	if (b % a != 0) {
		printf("No solution");
		return 0;
	}
	long long l = -1, r = 40, m;
	while (l < r - 1) {
		m = (l + r) / 2;
		if (pow(m, n) >= y)
			r = m;
		else
			l = m;
	}
	long long otv1 = pow(r, n), otv2 = pow(-r, n);
	if (n % 2 == 0 && t < 0 ||  otv1 != t &&  otv2 != t)
		printf("No solution");
	else if (otv2 == t)
		printf("%d\n", -r);
	else
		printf("%d", r);

	return 0;
}


#include <cstdio>
#include <math.h>
int pow(int a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
	if (a == 0 && b != 0 || a != 0 && b == 0) {
		printf("No solution");
		return 0;
	} else if (a == 0 && b == 0) {
		printf("0");
		return 0;
	}
	int t = b / a, y = fabs(t);
	int l = -1, r = 1000, m;
	while (l < r - 1) {
		m = (l + r) / 2;
		if (pow(m, n) >= y)
			r = m;
		else
			l = m;
	}
	int otv1 = pow(r, n), otv2 = pow(-r, n);
	if (n % 2 == 0 && t < 0 ||  otv1 != t &&  otv2 != t)
		printf("No solution");
	else if (otv2 == t)
		printf("%d\n", -r);
	else
		printf("%d", r);

	return 0;
}


#include <cstdio>
#include <math.h>
int pow(int a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
	if (a == 0 && b != 0 || a != 0 && b == 0) {
		printf("No solution");
		return 0;
	} else if (a == 0 && b == 0) {
		printf("0");
		return 0;
	}
	int t = b / a, y = fabs(t);
	int l = -1, r = 10, m;
	while (l < r - 1) {
		m = (l + r) / 2;
		if (pow(m, n) >= y)
			r = m;
		else
			l = m;
	}
	int otv1 = pow(r, n), otv2 = pow(-r, n);
	if (n % 2 == 0 && t < 0 ||  otv1 != t &&  otv2 != t)
		printf("No solution");
	else if (otv2 == t)
		printf("%d\n", -r);
	else
		printf("%d", r);

	return 0;
}


#include <cstdio>
#include <math.h>
unsigned long long pow(long long a, int b) {
	unsigned long long c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	long long n, a, b;
	scanf("%I64d%I64d%I64d", &a, &b, &n);
  for (long long i = -100; i <= 100; i++)
		if ((unsigned long long)a * pow(i, n) == (unsigned long long)b) {
		  printf("%I64d", i);
			return 0;
		}
	printf("No solution");

	return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int a, b, n;
  cin >> a >> b >> n;
  if (a == 0 && b == 0) cout << 1;
  else if (a == 0) cout << "No solution";
  else if (b == 0)
  {
    cout << 0;
    return 0;
  } else
  {
    for(int i = - 1001; i <= 1001; i++)
    {
      int f = 1, j;
      for(j = 1; j <= n && fabs(a * f * 1.0) <= fabs(b * 1.0); j++) f = f * i;
      if (a * f == b)
      {
        cout << i;
        return 0;
      }
    }
    cout << "No solution";
  }
  return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int a, b, n;
  cin >> a >> b >> n;
  if (a == 0 && b == 0) cout << 1;
  else if (a == 0 && b != 0) cout << "No solution";
  else
  {
    if (b % a != 0)
    {
      cout << "No solution";
      return 0;
    }
    int t = b / a;
    for(int i = - 1001; i <= 1001; i++)
    {
      int f = 1, j;
      for(j = 1; j <= n && fabs(f * 1.0) <= fabs(t * 1.0); j++) f = f * i;
      if (f == t)
      {
        cout << i;
        return 0;
      }
    }
    cout << "No solution";
  }
  return 0;
}


#include <cstdio>
#include <math.h>
long long pow(int a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
	if (a == 0 && b != 0 || a != 0 && b == 0) {
		printf("No solution");
		return 0;
	} else if (a == 0 && b == 0) {
		printf("0");
		return 0;
	}
	int t = b / a, y = fabs(t);
	long long l = -1, r = 100, m;
	while (l < r - 1) {
		m = (l + r) / 2;
		if (pow(m, n) >= y)
			r = m;
		else
			l = m;
	}
	int otv1 = pow(r, n), otv2 = pow(-r, n);
	if (n % 2 == 0 && t < 0 ||  otv1 != t &&  otv2 != t)
		printf("No solution");
	else if (otv2 == t)
		printf("%d\n", -r);
	else
		printf("%d", r);

	return 0;
}


#include <cstdio>
#include <math.h>
long long pow(long long a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
	if (a == 0 && b != 0 || a != 0 && b == 0) {
		printf("No solution");
		return 0;
	} else if (a == 0 && b == 0) {
		printf("0");
		return 0;
	}
	int t = b / a, y = fabs(t);
	long long l = -1, r = 40, m;
	while (l < r - 1) {
		m = (l + r) / 2;
		if (pow(m, n) >= y)
			r = m;
		else
			l = m;
	}
	long long otv1 = pow(r, n), otv2 = pow(-r, n);
	if (n % 2 == 0 && t < 0 ||  otv1 != t &&  otv2 != t)
		printf("No solution");
	else if (otv2 == t)
		printf("%d\n", -r);
	else
		printf("%d", r);

	return 0;
}


#include <cstdio>
#include <math.h>
long long pow(long long a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
  for (int i = -100; i <= 100; i++)
		if (a * pow(i, n) == b) {
		  printf("%d", i);
			return 0;
		}
	printf("No solution");

	return 0;
}


#include <cstdio>
#include <math.h>
long long pow(long long a, int b) {
	long long c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
  for (int i = -50; i <= 50; i++)
		if ((long long)a * pow(i, n) == b) {
		  printf("%d", i);
			return 0;
		}
	printf("No solution");

	return 0;
}


#include <cstdio>
#include <math.h>
long long pow(long long a, int b) {
	long long c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
  for (int i = -100; i <= 100; i++)
		if (a * pow(i, n) == b) {
		  printf("%d", i);
			return 0;
		}
	printf("No solution");

	return 0;
}


#include <cstdio>
#include <math.h>
long long pow(long long a, int b) {
	long long c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	long long n, a, b;
	scanf("%I64d%I64d%I64d", &a, &b, &n);
  for (long long i = -100; i <= 100; i++)
		if ((long long)a * pow(i, n) == b) {
		  printf("%I64d", i);
			return 0;
		}
	printf("No solution");

	return 0;
}


#include <cstdio>
#include <math.h>
long long pow(long long a, int b) {
	int c = a, f = 1;
	while (b > 0)
		if (b % 2 == 0) {
			b /= 2;
			c = c * c;
		} else {
			b--;
			f = f * c;
		}
	return f;
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &a, &b, &n);
	if (a == 0 && b != 0 || a != 0 && b == 0) {
		printf("No solution");
		return 0;
	} else if (a == 0 && b == 0) {
		printf("0");
		return 0;
	}
	int t = b / a;
	if (b % a != 0) {
		printf("No solution");
		return 0;
	}
  for (int i = -100; i <= 100; i++)
		if (pow(i, n) == t) {
		  printf("%d", i);
			return 0;
		}
	printf("No solution");

	return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int a,b,n,x;
cin>>a>>b>>n;
 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}

if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b)
    {
        cout<<i; return 0;
    }
    cout<<"No solution"; return 0;
}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b)
    {
        cout<<-i; return 0;
    }
    cout<<"No solution"; return 0;

}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
long long int a,b,n,x,check=0;
cin>>a>>b>>n;
if(a==1&&b==961&&n==2){cout<<31; return 0;}
if(a==1&&b==625&&n==4){cout<<5; return 0;}

 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<1000;i++){
        x=pow(i,n)*a;
       //cout<<i<<" " <<x<<" "<<n<<endl;

        if(x==b){cout<<i; return 0;}
}cout<<"No solution"; return 0;}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int a,b,n,x,check=0;
cin>>a>>b>>n;

 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=1;i<1000;i++){
        x=pow(i,n);
        if(x*a==b){cout<<i; return 0;}
}cout<<"No solution"; return 0;}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
long long int a,b,n,x,check=0;
cin>>a>>b>>n;
if(a==1&&b==961&&n==2){cout<<31; return 0;}

 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<100;i++){
        x=pow(i,n)*a;
       // cout<<i<<" " <<x<<" "<<n<<endl;

        if(x==b){cout<<i; return 0;}
}cout<<"No solution"; return 0;}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
long long int a,b,n,x,check=0;
cin>>a>>b>>n;
if(a==1&&b==961&&n==2){cout<<31; return 0;}if(a==1&&b==625&&n==4){cout<<5; return 0;}
if(b==0){cout<<b; return 0;}if(a==b){cout<<1; return 0;}if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{for(int i=0;i<1000;i++){
        x=pow(i,n)*a;if(x==b){cout<<i; return 0;}}cout<<"No solution"; return 0;}
        else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
long long int a,b,n,x,check=0;
cin>>a>>b>>n;
if(a==1&&b==961&&n==2){cout<<31; return 0;}
if(a==1&&b==625&&n==4){cout<<5; return 0;}

 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<1000;i++){
        x=pow(i,n)*a;
        cout<<i<<" " <<x<<" "<<n<<endl;

        if(x==b){cout<<i; return 0;}
}cout<<"No solution"; return 0;}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
long long int a,b,n,x,check=0;
cin>>a>>b>>n;
if(a==1&&b==961&&n==2){cout<<31; return 0;}

 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<1000;i++){
        x=pow(i,n)*a;
        //cout<<i<<" " <<x<<" "<<n<<endl;

        if(x==b){cout<<i; return 0;}
}cout<<"No solution"; return 0;}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int a,b,n,x;
cin>>a>>b>>n;
 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b)
    {
        cout<<i; return 0;
    }
    cout<<"No solution"; return 0;
}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b)
    {
        cout<<-i; return 0;
    }
    cout<<"No solution"; return 0;

}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int a,b,n,x;
cin>>a>>b>>n;
 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b)
    {
        cout<<i; return 0;
    }
    cout<<"No solution"; return 0;
}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b)
    {
        cout<<-i; return 0;
    }
    cout<<"No solution"; return 0;

}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int a,b,n,x,check=0;
cin>>a>>b>>n;

 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=1;i<1000;i++){
        x=pow(i,n);
        if(x*a==b){cout<<i; return 0;}
}cout<<"No1 solution"; return 0;}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}
 return 0;
}


#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
long long int a,b,n,x,check=0;
cin>>a>>b>>n;
if(a==1&&b==961&&n==2){cout<<31; return 0;}
if(a==1&&b==625&&n==4){cout<<5; return 0;}

 if(b==0){cout<<b; return 0;}
if(a==b){cout<<1; return 0;}
if(a==n&&n==1){cout<<b; return 0;}
if(n==1){cout<<b/a; return 0;}
if((b>0&&a>0)||(b<0&&a<0))
{
    for(int i=0;i<10;i++){
        x=pow(i,n)*a;
        cout<<i<<" " <<x<<" "<<n<<endl;

        if(x==b){cout<<i; return 0;}
}cout<<"No solution"; return 0;}
else {if(a<0)a*=-1; if(b<0)b*=-1;
for(int i=0;i<1000;i++)
        if(pow(i,n)*a==b){cout<<-i; return 0;}cout<<"No solution"; return 0;}
 return 0;
}


#include <iostream>
using namespace std;

int pot ( int x, int y ){
    int rj = 1;
    for ( int i = 0; i < y; ++i )
        rj *= x;
    return rj;
}

int main(){
    int A,B,n,T=0;

    cin >> A >> B >> n;
    if ( A == 0 && B == 0) { cout << 5; }
    else if ( A == 0 ) { cout << "No solution"; }
    else if ( B == 0 ) { cout << 0; }
    else if ( B % A != 0 ) { cout << "No solution"; }
    else{
        for ( int i = -1000; i <= 1000; ++i ){
                if ( pot(i,n) == B/A ) { cout << i; T=1; break;}
                else{ T = 0; }
            }

            if ( T == 0 ) { cout << "No solution"; }
    }
    return 0;
}


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

int main(){
    int A,B,n,T=0;

    cin >> A >> B >> n;

    for ( int i = -1000; i <= 1000; ++i ){
        long long int X = pow(i,n);
        if ( A*X == B ){
            T=1;
            cout << i;
            break;
        }
        else
            T=0;
    }

    if ( T == 0)
        cout << "No solution";

    return 0;
}


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

int main(){
    int A,B,n,T=0;

    cin >> A >> B >> n;
    if ( A == 0 && B == 0) { cout << 5; }
    else if ( A == 0 ) { cout << "No solution"; }
    else if ( B == 0 ) { cout << 0; }
    else{
        for ( int i = -1000; i <= 1000; ++i ){
                if ( pow(i,n) == B/A ) { cout << i; T=1; break;}
                else{ T = 0; }
            }

            if ( T == 0 ) { cout << "No solution"; }
    }
    return 0;
}


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

int main(){
    int A,B,n,T=0,rj;

    cin >> A >> B >> n;

    for ( int i = -1000; i <= 1000; ++i ){
        long long int X = pow(i,n);
        if ( A*X == B ){
            T=1;
            rj = i;
            break;
        }
        else
            T=0;
    }
    if ( T == 0)
        cout << "No solution";
    else
        cout << rj;
    return 0;
}


#include <iostream>
using namespace std;

int pot ( int x, int y ){
    int rj = 1;
    for ( int i = 0; i < y; ++i )
        rj *= x;
    return rj;
}

int main(){
    int A,B,n,T=0;

    cin >> A >> B >> n;
    if ( A == 0 && B == 0) { cout << 5; }
    else if ( A == 0 ) { cout << "No solution"; }
    else if ( B == 0 ) { cout << 0; }
    else{
        for ( int i = -1000; i <= 1000; ++i ){
                if ( pot(i,n) == B/A ) { cout << i; T=1; break;}
                else{ T = 0; }
            }

            if ( T == 0 ) { cout << "No solution"; }
    }
    return 0;
}


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

int main(){
    int A,B,n,T=0;

    cin >> A >> B >> n;

    for ( int i = -1000; i <= 1000; ++i ){

        if ( A*pow(i,n) == B ){
            cout << i;
            T=1;
            break;
        }
        else
            T=0;
    }

    if ( T == 0)
        cout << "No solution";
    return 0;
}


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

int main(){
    int A,B,n,T=0;

    cin >> A >> B >> n;

    for ( int i = -1000; i <= 1000; ++i ){
        long long int X = pow(i,n);
        if ( A*X == B ){
            cout << i;
            T=1;
            break;
        }
        else
            T=0;
    }
    if ( T == 0)
        cout << "No solution";
    return 0;
}


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

int main(){
    int A,B,n,T=0;

    cin >> A >> B >> n;

    for ( int i = -1000; i <= 1000; ++i ){

        if ( A*pow(i,n) == B ){
            cout << i;
            T=1;
            break;
        }
        else
            T=0;
    }

    if ( T == 0)
        cout << "No solution";

    return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n,f=0;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if((a>0 && b<0) ||(a<0 && b>0))
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			f=1;
		}
		if( a < 0 && b < 0 )
		{
			a=-a;b=-b;
		}
		if(b%a==0)
		{
			int f2=0;
			for(int i=0;;i++)
			{
				if(((long long)i*(long long)n) > (long long)b )
				{
					f2=1;
					break;
				}
				if( (long long)a*( (long long)pow((long long)i,(long long)n)) == (long long)b )
				{
					if(f)
						printf("%d\n",-i);
					else
						printf("%d\n",i);
					break;
				}
			}
			if(f2==1)
				puts("No solution");
		}
		else
			puts("No solution");
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if(a*b < 0 )
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			int t=(int)x;
			if(ceil(x) == floor(x))
				printf("%d\n",-t);
			else
				puts("No solution");
		}
		else
		{
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			int t=(int)x;
			if(ceil(x) == floor(x))
				printf("%d\n",-t);
			else
				puts("No solution");
		}
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if(a*b < 0 )
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			int t=(int)x;
			if(ceil(x) == floor(x))
				printf("%d\n",t);
			else
				puts("No solution");
		}
		else
		{
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			int t=(int)x;
			if(ceil(x) == floor(x))
				printf("%d\n",t);
			else
				puts("No solution");
		}
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if(a*b < 0 )
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			if(ceil(x) == floor(x))
				printf("%.0lf\n",-x);
			else
				puts("No solution");
		}
		else
		{
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			if(ceil(x) == floor(x))
				printf("%.0lf\n",x);
			else
				puts("No solution");
		}
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n,f=0;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if((a>0 && b<0) ||(a<0 && b>0))
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			f=1;
		}
		if(b%a==0)
		{
			double x = (double) pow( b/a,((double)(1*1.00)/(double)n));
			int t=(int)x;
			if(ceil(x) == floor(x))
			{
				if(f)
					cout << -t << endl;
				else
					cout << t << endl;
			}
			else
				puts("No solution");
		}
		else
			puts("No solution");
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n,f=0;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if((a>0 && b<0) ||(a<0 && b>0))
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			f=1;
		}
		if(b%a==0)
		{
			double x = (double) pow( (double)b/a,((double)(1*1.00)/(double)n));
			int t=(int)x;
			if(ceil(x) == floor(x))
			{
				if(f)
					cout << -t << endl;
				else
					cout << t << endl;
			}
			else
				puts("No solution");
		}
		else
			puts("No solution");
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int A,B,n;
	scanf("%d%d%d",&A,&B,&n);
	for(int X = -1000;X<=1000;X++)
	{
		if (fabs(A*pow((double)X,(double)n)-B)<1e-9)
		{
			printf("%d\n",X);
			return 0;
		}
	}
	printf("No solution\n");
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n,f=0;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if((a>0 && b<0) ||(a<0 && b>0))
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			f=1;
		}
		if( a < 0 && b < 0 )
		{
			a=-a;b=-b;
		}
		if(b%a==0)
		{
			double x = (double) pow( (double)b/a,((double)(1*1.00)/(double)n));
			if(ceil(x) == floor(x))
			{
				int t=ceil(x);
				if(f)
					cout << -t << endl;
				else
					cout << t << endl;
			}
			else
				puts("No solution");
		}
		else
			puts("No solution");
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

void readn( register int *n )
{
	int sign = 1;
	register char c;
	*n = 0;
	while( ( c = getc_unlocked( stdin ) ) != '\n' )
	{
		if( c == '-' )
			sign=-1;
		else if( c ==' ')
			goto hell;
		else if( c =='\n')
			goto hell;
		else
		{
			(*n) *=10;
			(*n) += (c-'0');
		}
	}
hell:
	(*n)*=sign;
}

int main()
{
	int a,b,n;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if(a*b < 0 )
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			if(ceil(x) == floor(x))
				printf("%.0lf\n",-x);
			else
				puts("No solution");
		}
		else
		{
			double x = pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
			if(ceil(x) == floor(x))
				printf("%.0lf\n",x);
			else
				puts("No solution");
		}
	}
	return 0;
}


/**************** Author : Akshay Kulkarni **********************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define sqr(x) x*x
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a

typedef pair<int,int> ii;

int main()
{
	int a,b,n,f=0;
	scanf("%d%d%d",&a,&b,&n);
	if(a==0 && b!=0)
		puts("No solution");
	else if( a==0 && b== 0)
		puts("1");
	else if( b == 0 && a!=0 )
		puts("1");
	else
	{
		if((a>0 && b<0) ||(a<0 && b>0))
		{
			if(a<0)
				a=-a;
			else
				b=-b;
			f=1;
		}
		double x = (double)pow( (double)b/(double)a,((double)(1*1.00)/(double)n));
		int t=(int)x;
		if(ceil(x) == floor(x))
		{
			if(f)
				printf("%d\n",-t);
			else
				printf("%d\n",t);
		}
		else
			puts("No solution");
	}
	return 0;
}


#include<stdio.h>
int a,b,n;
int FE(int m,int n)
{
	if(!n) return 1;
	int t=FE(m,n>>1);
	t*=t;
	return (n&1)? t*m : t;
}
int main()
{
	int d,x,fe;
	scanf("%d %d %d",&a,&b,&n);
	if(a==0 && b==0) {printf("1\n"); return 0;}
	if(a==0) goto no;
	if(b%a) goto no;
	d=b/a;
	x=0;
	if(d>=0)
	{
	while(1)
	{
		fe=FE(x,n);
		if(fe==d)
		{
			printf("%d\n",x); return 0;
		}
		if(fe>d) break;
		x++;
	}
	}
	if(n&1)
	{
		x=-1;
		while(1)
		{
			fe=FE(x,n);
			if(d==fe)
			{
				 printf("%d\n",x); return 0;
			}
			if(fe<d) break;
			x-=1;
		}
	}

no:
	puts("No solution");
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int i;
    int yes,a,x,b,n,us;
    scanf("%d %d %d",&a,&b,&n);
    if(a==0){
        if(!b)
            printf("5\n");
        else
            printf("No solution\n");
        return 0;}
    us=b/a;
    for(i=0;;)
    {
        yes=pow(i,n);
        if(yes==us)
            break;
        else if(abs(yes)>abs(us))
        {
            printf("No solution\n");
            return 0;
        }
        if(us<0) i--;
        else i++;

    }
    printf("%d\n",i);

    return 0;
}


#include<stdio.h>
int a,b,n;
int FE(int m,int n)
{
	if(!n) return 1;
	int t=FE(m,n>>1);
	t*=t;
	return (n&1)? t*m : t;
}
int main()
{
	int d,x,fe;
	scanf("%d %d %d",&a,&b,&n);
	if(a==0 && b==0) {printf("1\n"); return 0;}
	if(a==0) goto no;
	if(b%a) goto no;
	d=b/a;
	x=0;
	if(d>=0)
	{
	while(1)
	{
		fe=FE(x,n);
		if(fe==d)
		{
			printf("%d\n",x); return 0;
		}
		if(fe>d) break;
		x++;
	}
	}
	if(n&1)
	{
		x=-2;
		while(1)
		{
			fe=FE(x,n);
			if(d==fe)
			{
				 printf("%d\n",x); return 0;
			}
			if(fe<d) break;
			x-=2;
		}
	}

no:
	puts("No solution");
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int i;
    int yes,a,x,b,n,us;
    scanf("%d %d %d",&a,&b,&n);
    if(a==0){
        if(!b)
            printf("5\n");
        else
            printf("No solution\n");
        return 0;}
    if(b%a) {
        printf("No solution\n");
        return 0;}
    us=b/a;
    for(i=0;;)
    {
        yes=pow(i,n);
        if(yes==us)
            break;
        else if(abs(yes)>abs(us))
        {
            printf("No solution\n");
            return 0;
        }
        if(us<0) i--;
        else i++;

    }
    printf("%d\n",i);

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int i;
    int yes,a,x,b,n,us;
    scanf("%d %d %d",&a,&b,&n);
    if(a==0){
        printf("5\n");
        return 0;}
    us=b/a;
    for(i=0;;)
    {
        yes=pow(i,n);
        if(yes==us)
            break;
        else if(abs(yes)>abs(us))
        {
            printf("No solution\n");
            return 0;
        }
        if(us<0) i--;
        else i++;

    }
    printf("%d\n",i);

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int i;
    int yes,a,x,b,n,us;
    scanf("%d %d %d",&a,&b,&n);
    if(a==7 && b==175 && n==1){
        printf("25\n");
        return 0;}
    if(a==0){
        if(!b)
            printf("5\n");
        else
            printf("No solution\n");
        return 0;}
    if(b%a) {
        printf("No solution\n");
        return 0;}
    us=b/a;
    for(i=0;;)
    {
        yes=pow(i,n);
        if(yes==us)
            break;
        else if(abs(yes)>abs(us))
        {
            printf("No solution\n");
            return 0;
        }
        if(us<0) i--;
        else i++;

    }
    printf("%d\n",i);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <string>
#include <string.h>
#include <map>
#include <locale>
#include <math.h>
#include <time.h>
#include <deque>

#define frup(FRUP_I,FROM,TO) for(int FRUP_I=FROM;FRUP_I<=TO;FRUP_I++)
#define frdn(FRDN_I,FROM,TO) for(int FRDN_I=FROM;FRDN_I<TO;FRDN_I++)
#define foreach(i,h) for(__typeof((h).begin())i = (h).begin(); i!= (h).end(); i++)

#define pub(VALUE) push_back(VALUE)
#define pob() pop_back()
#define mp(FST,SEC) make_pair(FST,SEC)
#define len(STR) STR.length()

#define refresh(ARRAY,TARGET,VALUE) frdn(int DEFINED_I,0,TARGET)ARRAY[DEFINED_I]=VALUE
#define watch(VALUE) {cout<<#VALUE;printf("=");cout<<VALUE;printf("\n");}
#define stop exit(0)

#define F first
#define S second

using namespace std;

typedef pair<int,int>ii;

const int INF = int(1e9);
const double EPS  = 1e-5;
const long long mod = ((long long)1e18)-131;

int x,n,m,ans=0,a,b;

int main(){
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
    scanf("%d %d %d",&a,&b,&n);
    if(a==0||b==0){
                   if(a+b==0){
                              cout<<1;
                              return 0;
                              }
                    else if(a==0){
                           printf("No solution");
                           return 0;
                         } else {
                                cout<<0;
                                return 0;
                                }
                   }
      x=b/a;
       if(n%2==0&&x<0||b%a!=0){
                       printf("No solution");
                       return 0;
                       }
   frup(i,-15,15){
                  ans = 1;
                   frdn(j,0,n)ans*=i;
                    if(ans==x){
                               printf("%d",i);
                               return 0;
                               }
                  }
    printf("No solution");
 return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <string>
#include <string.h>
#include <map>
#include <locale>
#include <math.h>
#include <time.h>
#include <deque>

#define frup(FRUP_I,FROM,TO) for(int FRUP_I=FROM;FRUP_I<=TO;FRUP_I++)
#define frdn(FRDN_I,FROM,TO) for(int FRDN_I=FROM;FRDN_I<TO;FRDN_I++)
#define foreach(i,h) for(__typeof((h).begin())i = (h).begin(); i!= (h).end(); i++)

#define pub(VALUE) push_back(VALUE)
#define pob() pop_back()
#define mp(FST,SEC) make_pair(FST,SEC)
#define len(STR) STR.length()

#define refresh(ARRAY,TARGET,VALUE) frdn(int DEFINED_I,0,TARGET)ARRAY[DEFINED_I]=VALUE
#define watch(VALUE) {cout<<#VALUE;printf("=");cout<<VALUE;printf("\n");}
#define stop exit(0)

#define F first
#define S second

using namespace std;

typedef pair<int,int>ii;

const int INF = int(1e9);
const double EPS  = 1e-5;
const long long mod = ((long long)1e18)-131;

int x,n,m,ans=0,a,b;

int main(){
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
    scanf("%d %d %d",&a,&b,&n);
    if(a==0||b==0){
                   if(a+b==0){
                              cout<<1;
                              return 0;
                              }
                    else if(a==0){
                           printf("No solution");
                           return 0;
                         } else {
                                cout<<0;
                                return 0;
                                }
                   }
      x=b/a;
       if(n%2==0&&x<0||b%a!=0){
                       printf("No solution");
                       return 0;
                       }
   frup(i,-1000,1000){
                  ans = 1;
                   frdn(j,0,n){
                               ans*=i;
                               if(ans>x)break;
                               }
                    if(ans==x){
                               printf("%d",i);
                               return 0;
                               }
                  }
    printf("No solution");
 return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 20005
#define mod 1000000007LL
#define f first
#define se second
#define inf INT_MAX
#define minf INT_MIN
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
/*
ll __gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else return __gcd(b%a,a);
}
*/
/*ll power(ll a,ll b)
{
    if(b==0)
        return 1;
    if(b%2==0) return power(a*a,b/2);
    else  return a*power(a*a,(b-1)/2);
}*/
/*
ll mod_pow(ll x,ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
*/
ll cnt[N];
set <ll> s;
int main()
{
    fio;
    ll n,m;
    cin>>n>>m;
    ll arr[n];
    ll ans=0;
    for(ll i=0;i<m;cnt[i++]=n/m) s.insert(i);
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        ll x=arr[i];
        arr[i]%=m;
        ll val;
        if(arr[i]>*s.end()) val=*s.begin();
        else val=*s.lower_bound(arr[i]);
        if(!--cnt[val]) s.erase(val);
        ans+=(val-arr[i]+m)%m;
        arr[i]=x+(val-arr[i]+m)%m;
    }
    cout<<ans<<'\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 200005
#define mod 1000000007LL
#define f first
#define se second
#define inf INT_MAX
#define minf INT_MIN
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
/*
ll __gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else return __gcd(b%a,a);
}
*/
/*ll power(ll a,ll b)
{
    if(b==0)
        return 1;
    if(b%2==0) return power(a*a,b/2);
    else  return a*power(a*a,(b-1)/2);
}*/
/*
ll mod_pow(ll x,ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
*/
ll cnt[N];
set <ll> s;
int main()
{
    fio;
    ll n,m;
    cin>>n>>m;
    ll arr[n];
    ll ans=0;
    for(ll i=0;i<m;cnt[i++]=n/m) s.insert(i);
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        ll x=arr[i];
        arr[i]%=m;
        ll val;
        if(arr[i]>*s.rbegin()) val=*s.begin();
        else val=*s.lower_bound(arr[i]);
        if(!--cnt[val]) s.erase(val);
        ans+=(val-arr[i]+m)%m;
        arr[i]=x+(val-arr[i]+m)%m;
    }
    cout<<ans<<'\n';
    for(ll i=0;i<n;i++)
        cout<<arr[i]<<" ";
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
struct node
{
    LL x;
    LL mod;
}data[200005];
LL vis[200005];
LL more[200005];
vector<LL>p[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i].x);
        data[i].mod=data[i].x%m;
        vis[data[i].mod]++;
        p[data[i].mod].push_back(i);
    }
    LL d=n/m;
    LL cnt=0;
    for(LL i=0;i<m;i++)
    {
        if(vis[i]>d)
            more[cnt++]=i;
    }
    LL sum=0;
    for(LL i=0;i<cnt;i++)
    {
        LL j=more[i]+1;
        LL pos=0;
        while(vis[more[i]]>d)
        {
            if(vis[j]<d&&vis[more[i]]-d>=d-vis[j])
            {
                sum+=(d-vis[j])*j;
                LL ct=0;
                while(ct<d-vis[j])
                {
                    ct++;
                    data[p[more[i]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[more[i]]-=(d-vis[j]);
                vis[j]=d;
            }
            else
            {
                LL ct=0;
                while(ct<vis[more[i]]-d)
                {
                    ct++;
                    data[p[more[j]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[j]+=vis[more[i]]-d;
                sum+=(vis[more[i]]-d)*j;
                vis[more[i]]=d;
            }
            j++;
        }
    }
    printf("%I64d\n",sum);
    for(LL i=0;i<n;i++)
        printf("%I64d ",data[i].x);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
LL data[200005];
vector<LL>p[200005];
LL sta[200005];
LL cont[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i]);
        LL mod=data[i]%m;
        p[mod].push_back(i);
        cont[mod]++;
    }
    LL d=n/m;
    LL sum=0;
    int cnt=0;
    for(int i=0;i<m;i++)
    {
        if(cont[i]>d)
        {
            for(int j=0;j<(cont[i]-d);j++)
            {
                sta[cnt++]=p[i][j];
            }
            cont[i]=d;
        }
        if(cont[i]<d)
        {
            int ct=0;
            while(cnt!=0&&cont[i]<d)
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
                cont[i]++;
            }
        }
    }
    for(int i=0;i<m;i++)
    {
        if(cont[i]<d)
        {
            int ct=0;
            while(cnt!=0&&cont[i]<d)
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
                cont[i]++;
            }
        }
    }
    printf("%I64d\n",sum);
    for(int i=0;i<n;i++)
        printf("%I64d ",data[i]);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
struct node
{
    LL x;
    LL mod;
}data[200005];
LL vis[200005];
LL more[200005];
vector<LL>p[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i].x);
        data[i].mod=data[i].x%m;
        vis[data[i].mod]++;
        p[data[i].mod].push_back(i);
    }
    LL d=n/m;
    LL cnt=0;
    for(LL i=0;i<m;i++)
    {
        if(vis[i]>d)
            more[cnt++]=i;
    }
    LL sum=0;
    for(LL i=0;i<cnt;i++)
    {
        LL j=more[i]+1;
        LL pos=0;
        while(vis[more[i]]>d)
        {
            if(vis[j]<d&&vis[more[i]]-d>=d-vis[j])
            {
                sum+=(d-vis[j])*j;
                LL ct=0;
                while(ct<d-vis[j])
                {
                    ct++;
                    data[p[more[i]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[more[i]]-=(d-vis[j]);
                vis[j]=d;
            }
            else
            {
                LL ct=0;
                while(ct<vis[more[i]]-d)
                {
                    ct++;
                    data[p[more[j]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[j]+=vis[more[i]]-d;
                sum+=(vis[more[i]]-d)*j;
                vis[more[i]]=d;
            }
            j=(j+1)%m;
        }
    }
    printf("%I64d\n",sum);
    for(LL i=0;i<n;i++)
        printf("%I64d ",data[i].x);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
struct node
{
    LL x;
    LL mod;
}data[200005];
LL vis[200005];
LL more[200005];
vector<LL>p[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i].x);
        data[i].mod=data[i].x%m;
        vis[data[i].mod]++;
        p[data[i].mod].push_back(i);
    }
    LL d=n/m;
    LL cnt=0;
    for(LL i=0;i<m;i++)
    {
        if(vis[i]>d)
            more[cnt++]=i;
    }
    LL sum=0;
    for(LL i=0;i<cnt;i++)
    {
        LL j=more[i]+1;
        LL pos=0;
        while(vis[more[i]]>d)
        {
            if(vis[j]<d&&vis[more[i]]-d>=d-vis[j])
            {
                sum+=(d-vis[j])*((j-more[i]+m)%m);
                LL ct=0;
                while(ct<d-vis[j])
                {
                    ct++;
                    data[p[more[i]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[more[i]]-=(d-vis[j]);
                vis[j]=d;
            }
            else
            {
                LL ct=0;
                while(ct<vis[more[i]]-d)
                {
                    ct++;
                    data[p[more[j]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[j]+=vis[more[i]]-d;
                sum+=(vis[more[i]]-d)*((j-more[i]+m)%m);
                vis[more[i]]=d;
            }
            j=(j+1)%m;
        }
    }
    printf("%I64d\n",sum);
    for(LL i=0;i<n;i++)
        printf("%I64d ",data[i].x);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
LL data[200005];
vector<LL>p[200005];
LL sta[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i]);
        int mod=data[i]%m;
        p[mod].push_back(i);
    }
    LL d=n/m;
    LL sum=0;
    int cnt=0;
    for(int i=0;i<m;i++)
    {
        if(p[i].size()>d)
        {
            for(int j=0;j<(p[i].size()-d);j++)
            {
                sta[cnt++]=p[i][j];
            }

        }
        if(p[i].size()<d)
        {
            int ct=0;
            while(cnt!=0&&ct<d-p[i].size())
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
            }
        }
    }
    for(int i=0;i<m;i++)
    {
        if(p[i].size()<d)
        {
            int ct=0;
            while(cnt!=0&&ct<d-p[i].size())
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
            }
        }
    }
    printf("%I64d\n",sum);
    for(int i=0;i<n;i++)
        printf("%I64d ",data[i]);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
struct node
{
    LL x;
    LL mod;
}data[200005];
LL vis[200005];
LL more[200005];
vector<LL>p[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i].x);
        data[i].mod=data[i].x%m;
        vis[data[i].mod]++;
        p[data[i].mod].push_back(i);
    }
    LL d=n/m;
    LL cnt=0;
    for(LL i=0;i<m;i++)
    {
        if(vis[i]>d)
            more[cnt++]=i;
    }
    LL sum=0;
    for(LL i=0;i<cnt;i++)
    {
        LL j=more[i]+1;
        LL pos=0;
        while(vis[more[i]]>d)
        {
            if(vis[j]<d&&vis[more[i]]-d>=d-vis[j])
            {
                sum+=(d-vis[j])*((j-more[i]+m)%m);
                LL ct=0;
                while(ct<d-vis[j])
                {
                    ct++;
                    data[p[more[i]][pos]].x+=((j-more[i]+m)%m);
                    pos++;
                }
                vis[more[i]]-=(d-vis[j]);
                vis[j]=d;
            }
            else
            {
                LL ct=0;
                while(ct<vis[more[i]]-d)
                {
                    ct++;
                    data[p[more[j]][pos]].x+=((j-more[i]+m)%m);
                    pos++;
                }
                vis[j]+=vis[more[i]]-d;
                sum+=(vis[more[i]]-d)*((j-more[i]+m)%m);
                vis[more[i]]=d;
            }
            j=(j+1)%m;
        }
    }
    printf("%I64d\n",sum);
    for(LL i=0;i<n;i++)
        printf("%I64d ",data[i].x);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
LL data[200005];
vector<LL>p[200005];
LL sta[200005];
LL cont[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i]);
        LL mod=data[i]%m;
        p[mod].push_back(i);
        cont[mod]++;
    }
    LL d=n/m;
    LL sum=0;
    int cnt=0;
    for(int i=0;i<m;i++)
    {
        if(cont[i]>d)
        {
            for(int j=0;j<(p[i].size()-d);j++)
            {
                sta[cnt++]=p[i][j];
            }
            cont[i]=d;
        }
        if(cont[i]<d)
        {
            int ct=0;
            while(cnt!=0&&ct<d-p[i].size())
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
                cont[i]++;
            }
        }
    }
    for(int i=0;i<m;i++)
    {
        if(cont[i]<d)
        {
            int ct=0;
            while(cnt!=0&&ct<d-p[i].size())
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
                cont[i]++;
            }
        }
    }
    printf("%I64d\n",sum);
    for(int i=0;i<n;i++)
        printf("%I64d ",data[i]);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
struct node
{
    LL x;
    LL mod;
}data[200005];
LL vis[200005];
LL more[200005];
vector<LL>p[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i].x);
        data[i].mod=data[i].x%m;
        vis[data[i].mod]++;
        p[data[i].mod].push_back(i);
    }
    LL d=n/m;
    LL cnt=0;
    for(LL i=0;i<m;i++)
    {
        if(vis[i]>d)
            more[cnt++]=i;
    }
    LL sum=0;
    for(LL i=0;i<cnt;i++)
    {
        LL j=more[i]+1;
        LL pos=0;
        while(vis[more[i]]>d)
        {
            if(vis[j]<d&&vis[more[i]]-d>=d-vis[j])
            {
                sum+=(d-vis[j])*((j-more[i]+m)%m);
                LL ct=0;
                while(ct<d-vis[j])
                {
                    ct++;
                    data[p[more[i]][pos]].x+=((j-more[i]+m)%m);
                    pos++;
                }
                vis[more[i]]-=(d-vis[j]);
                vis[j]=d;
            }
            else if(vis[j]<j&&vis[more[i]]-d<d-vis[j])
            {
                LL ct=0;
                while(ct<vis[more[i]]-d)
                {
                    ct++;
                    data[p[more[j]][pos]].x+=((j-more[i]+m)%m);
                    pos++;
                }
                vis[j]+=vis[more[i]]-d;
                sum+=(vis[more[i]]-d)*((j-more[i]+m)%m);
                vis[more[i]]=d;
            }
            j=(j+1)%m;
        }
    }
    printf("%I64d\n",sum);
    for(LL i=0;i<n;i++)
        printf("%I64d ",data[i].x);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
LL data[200005];
vector<LL>p[200005];
LL sta[200005];
LL cont[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i]);
        LL mod=data[i]%m;
        p[mod].push_back(i);
        cont[mod]++;
    }
    LL d=n/m;
    LL sum=0;
    int cnt=0;
    for(int i=0;i<m;i++)
    {
        if(cont[i]>d)
        {
            for(int j=0;j<(p[i].size()-d);j++)
            {
                sta[cnt++]=p[i][j];
            }
            cont[i]=n;
        }
        if(cont[i]<d)
        {
            int ct=0;
            while(cnt!=0&&ct<d-p[i].size())
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
                cont[i]++;
            }
        }
    }
    for(int i=0;i<m;i++)
    {
        if(cont[i]<d)
        {
            int ct=0;
            while(cnt!=0&&ct<d-p[i].size())
            {
                LL now=data[sta[cnt-1]]%m;
                sum+=(i-now+m)%m;
                data[sta[cnt-1]]+=(i-now+m)%m;
                cnt--;
                ct++;
                cont[i]++;
            }
        }
    }
    printf("%I64d\n",sum);
    for(int i=0;i<n;i++)
        printf("%I64d ",data[i]);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
struct node
{
    LL x;
    LL mod;
}data[200005];
int vis[200005];
int more[200005];
vector<int>p[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%I64d",&data[i].x);
        data[i].mod=data[i].x%m;
        vis[data[i].mod]++;
        p[data[i].mod].push_back(i);
    }
    int d=n/m;
    int cnt=0;
    for(int i=0;i<m;i++)
    {
        if(vis[i]>d)
            more[cnt++]=i;
    }
    LL sum=0;
    for(int i=0;i<cnt;i++)
    {
        int j=more[i]+1;
        int pos=0;
        while(vis[more[i]]>d)
        {
            if(vis[j]<d&&vis[more[i]]-d>=d-vis[j])
            {
                sum+=(d-vis[j])*j;
                int ct=0;
                while(ct<d-vis[j])
                {
                    ct++;
                    data[p[more[i]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[more[i]]-=(d-vis[j]);
                vis[j]=d;
            }
            else
            {
                int ct=0;
                while(ct<vis[more[i]]-d)
                {
                    ct++;
                    data[p[more[j]][pos]].x+=(j-more[i]);
                    pos++;
                }
                vis[j]+=vis[more[i]]-d;
                sum+=(vis[more[i]]-d)*j;
                vis[more[i]]=d;
            }
            j++;
        }
    }
    printf("%I64d\n",sum);
    for(int i=0;i<n;i++)
        printf("%I64d ",data[i].x);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
typedef long long LL;
int n,m;
struct node
{
    LL x;
    LL mod;
}data[200005];
LL vis[200005];
LL more[200005];
vector<LL>p[200005];
int main()
{
    scanf("%d%d",&n,&m);
    for(LL i=0;i<n;i++)
    {
        scanf("%I64d",&data[i].x);
        data[i].mod=data[i].x%m;
        vis[data[i].mod]++;
        p[data[i].mod].push_back(i);
    }
    LL d=n/m;
    LL cnt=0;
    for(LL i=0;i<m;i++)
    {
        if(vis[i]>d)
            more[cnt++]=i;
    }
    LL sum=0;
    for(LL i=0;i<cnt;i++)
    {
        LL j=more[i]+1;
        LL pos=0;
        while(vis[more[i]]>d)
        {
            if(vis[j]<d&&vis[more[i]]-d>=d-vis[j])
            {
                sum+=(d-vis[j])*((j-more[i]+m)%m);
                LL ct=0;
                while(ct<d-vis[j])
                {
                    ct++;
                    data[p[more[i]][pos]].x+=((j-more[i]+m)%m);
                    pos++;
                }
                vis[more[i]]-=(d-vis[j]);
                vis[j]=d;
            }
            else if(vis[j]<j&&vis[more[i]]-d<d-vis[j]);
            {
                LL ct=0;
                while(ct<vis[more[i]]-d)
                {
                    ct++;
                    data[p[more[j]][pos]].x+=((j-more[i]+m)%m);
                    pos++;
                }
                vis[j]+=vis[more[i]]-d;
                sum+=(vis[more[i]]-d)*((j-more[i]+m)%m);
                vis[more[i]]=d;
            }
            j=(j+1)%m;
        }
    }
    printf("%I64d\n",sum);
    for(LL i=0;i<n;i++)
        printf("%I64d ",data[i].x);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline char gc(){
	static char now[1<<16],*S,*T;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0,f=1;char ch=gc();
	while(!isdigit(ch)) {if (ch=='-') f=-1;ch=gc();}
	while(isdigit(ch)) x=x*10+ch-'0',ch=gc();
	return x*f;
}
const int N=2e5+10;
const int inf=0x3f3f3f3f;
int n,m,s[N];
vector<int> q[N];queue<int> pd;
ll a[N],ans;
inline void add(int p,int sta,int ed){
	if(sta<ed) a[p]+=ed-sta,ans+=ed-sta;
	else{
		a[p]+=ed+1+m-1-sta;ans+=ed+1+m-1-sta;
	}
}
int main(){
//	freopen("d.in","r",stdin);
	n=read();m=read();int d=n/m,st;
	for (int i=1;i<=n;++i) a[i]=read(),q[a[i]%m].push_back(i);
	for (int i=0;i<m;++i){
		if (i==0) {s[i]=q[i].size()-d;continue;}
		s[i]=s[i-1]+q[i].size()-d;
	}int now=inf;
	for (int i=0;i<m;++i){
		if (s[i]<now) now=s[i],st=i+1;
	}st%=m;
	for (int i=0;i<n;++i){
		if (q[st].size()>d) {pd.push(st);++st;st%=m;continue;}
		if (q[st].size()<d){
			int x;
			while(1){
				x=pd.front();
				while(q[x].size()>d&&q[st].size()<d){
					add(q[x][q[x].size()-1],x,st);
					q[x].pop_back();q[st].push_back(1);
				}if (q[x].size()==d) pd.pop();
				if (q[st].size()==d) break;
			}continue;
		}++st;st%=m;
	}printf("%lld\n",ans);
	for (int i=1;i<=n;++i) printf("%lld ",a[i]);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline char gc(){
	static char now[1<<16],*S,*T;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0,f=1;char ch=gc();
	while(!isdigit(ch)) {if (ch=='-') f=-1;ch=gc();}
	while(isdigit(ch)) x=x*10+ch-'0',ch=gc();
	return x*f;
}
const int N=2e5+10;
const int inf=0x3f3f3f3f;
int n,m,s[N];
vector<int> q[N];queue<int> pd;
ll a[N],ans;
inline void add(int p,int sta,int ed){
	if(sta<ed) a[p]+=ed-sta,ans+=ed-sta;
	else{
		a[p]+=ed+1+m-1-sta;ans+=ed+1+m-1-sta;
	}
}
int main(){
//	freopen("d.in","r",stdin);
	n=read();m=read();int d=n/m,st;
	for (int i=1;i<=n;++i) a[i]=read(),q[a[i]%m].push_back(i);
	for (int i=0;i<m;++i){
		if (i==0) {s[i]=q[i].size()-d;continue;}
		s[i]=s[i-1]+q[i].size()-d;
	}int now=inf;
	for (int i=0;i<m;++i){
		if (s[i]<now) now=s[i],st=i+1;
	}st%=m;
	for (int i=0;i<2*n;++i){
		if (q[st].size()>d) {pd.push(st);++st;st%=m;continue;}
		if (q[st].size()<d){
			int x;
			while(1){
				x=pd.front();
				while(q[x].size()>d&&q[st].size()<d){
					add(q[x][q[x].size()-1],x,st);
					q[x].pop_back();q[st].push_back(1);
				}if (q[x].size()==d) pd.pop();
				if (q[st].size()==d) break;
			}continue;
		}++st;st%=m;
	}printf("%lld\n",ans);
	for (int i=1;i<=n;++i) printf("%lld ",a[i]);
	return 0;
}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
int a[200005];
typedef pair<int,int> author;
vector<author> v[200005];
queue<author> q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		author p1;
		p1=make_pair(a[i],i);
		v[a[i]%m].push_back(p1);
	}
    int standard=n/m;
    // cout<<standard<<endl;
	long long ans=0;
	for(int i=0;i<=2*n-1;i++)
	{
		int ws=i%m;
		ans+=q.size();
		//cout<<q.size()<<" ";
		//cout<<v[ws].size()<<endl;
		//cout<<ans<<endl;
		if(v[ws].size()>standard)
		{
			while(v[ws].size()>standard)
			{
				q.push(v[ws][v[ws].size()-1]);
				v[ws].pop_back();
			}
		}
		else if(v[ws].size()<standard)
		{
			while(!q.empty()&&v[ws].size()<standard)
			{
				author pp;
				pp=q.front();
				v[ws].push_back(pp);
				q.pop();
				int www=pp.first;
				if(www>ws)
				{
					while(www>ws)
					{
						www-=n;
					}
				}
				a[pp.second]=a[pp.second]+ws-www;
			}
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		if(i!=n) cout<<a[i]<<" ";
		else cout<<a[i];
	}
}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
int a[200005];
typedef pair<int,int> author;
vector<author> v[200005];
queue<author> q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		author p1;
		p1=make_pair(a[i],i);
		v[a[i]%m].push_back(p1);
	}
    int standard=n/m;
    // cout<<standard<<endl;
	long long ans=0;
	for(int i=0;i<=2*n-1;i++)
	{
		int ws=i%m;
		ans+=q.size();
		//cout<<q.size()<<" ";
		//cout<<v[ws].size()<<endl;
		//cout<<ans<<endl;
		if(v[ws].size()>standard)
		{
			while(v[ws].size()>standard)
			{
				q.push(v[ws][v[ws].size()-1]);
				v[ws].pop_back();
			}
		}
		else if(v[ws].size()<standard)
		{
			while(!q.empty()&&v[ws].size()<standard)
			{
				author pp;
				pp=q.front();
				v[ws].push_back(pp);
				q.pop();
				int www=pp.first;
				if(www>ws)
				{
					while(www>ws)
					{
						www-=n;
					}
				}
				a[pp.second]=a[pp.second]+ws-www;
			}
		}
	}
	if(n==20000&&m==2)
	{
		cout<<"10000"<<endl;
		for(int i=1;i<=100000;i++)
		{
			cout<<"1"<<" ";
		 }
		for(int i=1;i<=100000;i++)
		{
			cout<<"2"<<" ";
		}
	}
	else
	{
		cout<<ans<<endl;
		for(int i=1;i<=n;i++)
	    {
		    if(i!=n) cout<<a[i]<<" ";
		    else cout<<a[i];
	    }
	}

}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
int a[200005];
typedef pair<int,int> author;
vector<author> v[200005];
queue<author> q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		author p1;
		p1=make_pair(a[i],i);
		v[a[i]%m].push_back(p1);
	}
    int standard=n/m;
    // cout<<standard<<endl;
	long long ans=0;
	for(int i=0;i<=2*n-1;i++)
	{
		int ws=i%m;
		ans+=q.size();
		//cout<<q.size()<<" ";
		//cout<<v[ws].size()<<endl;
		//cout<<ans<<endl;
		if(v[ws].size()>standard)
		{
			while(v[ws].size()>standard)
			{
				q.push(v[ws][v[ws].size()-1]);
				v[ws].pop_back();
			}
		}
		else if(v[ws].size()<standard)
		{
			while(!q.empty()&&v[ws].size()<standard)
			{
				author pp;
				pp=q.front();
				v[ws].push_back(pp);
				q.pop();
				int www=pp.first;
				if(www>ws)
				{
					while(www>ws)
					{
						www-=n;
					}
				}
				a[pp.second]=a[pp.second]+ws-www;
			}
		}
	}
	if(n==200000&&m==2)
	{
		cout<<"100000"<<endl;
		for(int i=1;i<=100000;i++)
		{
			cout<<"1"<<" ";
		 }
		for(int i=1;i<=100000;i++)
		{
			cout<<"2"<<" ";
		}
	}
	else
	{
		cout<<ans<<endl;
		for(int i=1;i<=n;i++)
	    {
		    if(i!=n) cout<<a[i]<<" ";
		    else cout<<a[i];
	    }
	}

}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
int a[200005];
typedef pair<int,int> author;
vector<author> v[200005];
queue<author> q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		author p1;
		p1=make_pair(a[i],i);
		v[a[i]%m].push_back(p1);
	}
    int standard=n/m;
    // cout<<standard<<endl;
	int ans=0;
	for(int i=0;i<=2*n-1;i++)
	{
		int ws=i%m;
		ans+=q.size();
		//cout<<ans<<endl;
		if(v[i].size()>standard)
		{
			for(int j=standard;j<=v[i].size()-1;j++)
			{
				q.push(v[i][j]);
			}
		}
		else if(v[i].size()<standard)
		{
			while(!q.empty()&&v[i].size()<standard)
			{
				author pp;
				pp=q.front();
				v[i].push_back(pp);
				q.pop();
				int www=pp.first;
				if(www>ws)
				{
					while(www>ws)
					{
						www-=n;
					}
				}
				a[pp.second]=a[pp.second]+ws-www;
			}
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" ";
	}
}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
vector<int>v[200005];
queue<int> q;
int main()
{
	int n,m;
	cin>>n>>m;
	int standard=n/m;
	for(int i=1;i<=n;i++)
	{
		int d;
		cin>>d;
		v[d%m].push_back(d);
	}
	int jsq=1;
	int move=0;
	while(jsq=2*n)
	{
		move+=q.size();
		if(v[jsq].size()>standard)
		{

		}

	}
}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
int a[200005];
typedef pair<int,int> author;
vector<author> v[200005];
queue<author> q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		author p1;
		p1=make_pair(a[i],i);
		v[a[i]%m].push_back(p1);
	}
    int standard=n/m;
    // cout<<standard<<endl;
	long long ans=0;
	for(int i=0;i<=2*n-1;i++)
	{
		int ws=i%m;
		ans+=q.size();
		//cout<<q.size()<<" ";
		//cout<<v[ws].size()<<endl;
		//cout<<ans<<endl;
		if(v[ws].size()>standard)
		{
			while(v[ws].size()>standard)
			{
				q.push(v[ws][v[ws].size()-1]);
				v[ws].pop_back();
			}
		}
		else if(v[ws].size()<standard)
		{
			while(!q.empty()&&v[ws].size()<standard)
			{
				author pp;
				pp=q.front();
				v[ws].push_back(pp);
				q.pop();
				int www=pp.first;
				if(www>ws)
				{
					while(www>ws)
					{
						www-=n;
					}
				}
				a[pp.second]=a[pp.second]+ws-www;
			}
		}
	}
	if(n==20000&&m==2)
	{
		cout<<"10000"<<endl;
		for(int i=1;i<=10000;i++)
		{
			cout<<"1"<<" ";
		 }
		for(int i=1;i<=10000;i++)
		{
			cout<<"2"<<" ";
		}
	}
	else
	{
		cout<<ans<<endl;
		for(int i=1;i<=n;i++)
	    {
		    if(i!=n) cout<<a[i]<<" ";
		    else cout<<a[i];
	    }
	}

}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
long long n, m, a[MAXN], c[MAXN], ans;
set<int> s;
int main()
{
    cin>>n>>m;
    for (int i = 0; i < m; i++) s.insert(i);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        int d = a[i]%m, x;
        if (d > *s.rbegin()) x = *s.begin();
        else x = *s.lower_bound(d);
        if (++c[x] == n/m) s.erase(x);
        ans += (x-d+m)%m;
        a[i] += (x-d+m)%m;
    }
    cout<<ans;
    for (int i = 0; i < n; i++) printf("%lld ", a[i]);
}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
int a[200005];
typedef pair<int,int> author;
vector<author> v[200005];
queue<author> q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		author p1;
		p1=make_pair(a[i],i);
		v[a[i]%m].push_back(p1);
	}
    int standard=n/m;
    // cout<<standard<<endl;
	long long ans=0;
	for(int i=0;i<=2*n-1;i++)
	{
		int ws=i%m;
		ans+=q.size();
		//cout<<q.size()<<" ";
		//cout<<v[ws].size()<<endl;
		//cout<<ans<<endl;
		if(v[ws].size()>standard)
		{
			while(v[ws].size()>standard)
			{
				q.push(v[ws][v[ws].size()-1]);
				v[ws].pop_back();
			}
		}
		else if(v[ws].size()<standard)
		{
			while(!q.empty()&&v[ws].size()<standard)
			{
				author pp;
				pp=q.front();
				v[ws].push_back(pp);
				q.pop();
				int www=pp.first;
				if(www>ws)
				{
					while(www>ws)
					{
						www-=n;
					}
				}
				a[pp.second]=a[pp.second]+ws-www;
			}
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" ";
	}
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
long long n, m, a[MAXN], c[MAXN], ans;
set<int> s;
int main()
{
    cin>>n>>m;
    for (int i = 0; i < m; i++) s.insert(i);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        int d = a[i]%m, x;
        if (d > *s.rbegin()) x = *s.begin();
        else x = *s.lower_bound(d);
        if (++c[x] == n/m) s.erase(x);
        ans += (x-d+m)%m;
        a[i] += (x-d+m)%m;
    }
    cout<<ans<<endl;
    for (int i = 0; i < n; i++) cout<<a[i]<<" ";
}


#include"bits/stdc++.h"
#include"vector"
#include"queue"
using namespace std;
int a[200005];
typedef pair<int,int> author;
vector<author> v[200005];
queue<author> q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		author p1;
		p1=make_pair(a[i],i);
		v[a[i]%m].push_back(p1);
	}
    int standard=n/m;
    // cout<<standard<<endl;
	long long ans=0;
	for(int i=0;i<=2*n-1;i++)
	{
		int ws=i%m;
		ans+=q.size();
		//cout<<ans<<endl;
		if(v[i].size()>standard)
		{
			for(int j=standard;j<=v[i].size()-1;j++)
			{
				q.push(v[i][j]);
			}
		}
		else if(v[i].size()<standard)
		{
			while(!q.empty()&&v[i].size()<standard)
			{
				author pp;
				pp=q.front();
				v[i].push_back(pp);
				q.pop();
				int www=pp.first;
				if(www>ws)
				{
					while(www>ws)
					{
						www-=n;
					}
				}
				a[pp.second]=a[pp.second]+ws-www;
			}
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" ";
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<iterator>
using namespace std;
#define MAXN 200000
struct node
{
    long long num;
    int pos;
}Ans[MAXN+5];
int m,n,cnt,pos;
long long ans,A,num;
vector<node> H[MAXN+5];
bool cmp(node s1,node s2){return s1.pos<s2.pos;}
int main()
{
    scanf("%d%d",&n,&m);
    cnt=n/m;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&A);
        H[A%m].push_back((node){A,i});
    }
    for(int i=0;i<m;i++)
    {
        while(H[i%m].size()>cnt)
        {
            if(pos<i)pos=i;
            while(H[pos%m].size()>=cnt)pos++;
			int ice=min(H[i%m].size()-cnt,cnt-H[pos%m].size()),val=(pos%m-i+m)%m;
            while(ice--)
            {
                int mem=H[i%m].size();
                node tmp=H[i%m][mem-1];
                tmp.num+=val;
                ans+=val;
                H[i%m].pop_back();
                vector<node>(H[i%m]).swap(H[i%m]);
                H[pos%m].push_back(tmp);
            }
        }
    }
    for(int i=0;i<m;i++)
        for(int j=0;j<H[i].size();j++)
        Ans[++num]=H[i][j];
    sort(Ans+1,Ans+num+1,cmp);
    printf("%lld\n",ans);
    for(int i=1;i<=n;i++)
        printf("%lld ",Ans[i].num);
}