You have number *a*, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.

Number *a* doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
The first line contains positive integer *a* in the decimal record. It is guaranteed that the record of number *a* contains digits: 1, 6, 8, 9. Number *a* doesn't contain any leading zeroes. The decimal representation of number *a* contains at least 4 and at most 10<sup class="upper-index">6</sup> characters.
#include <bits/stdc++.h>
#define IOS	   ios_base::sync_with_stdio(false), cin.tie(0);
#define MP 	   make_pair
#define PB 	   push_back
#define FI 	   first
#define SE	   second
#define ALL(a) a.begin(),a.end()
#define SZ(a)  (long long int)(a.size())
#define FORA(i,s,e,st)	for(i=s; i<e; i+=st)
#define FORD(i,s,e,st)	for(i=s; i>e; i-=st)
#define FORE(it,c)      for(it=c.begin(); it!=c.end(); it++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector< vi > vvi;
const ll MOD= 1e9+7;
const long double EPS=1e-6;
#define MAX  10000000
ll euler_tot(ll a)
{
	ll b, temp=a;
	for(b=2;b<a; b++)
	{
		if(a%b==0)
			a=(a/b)*(b-1);
	}
	if(temp==a)
		a-=1;
	return a;
}
int main()
{
	IOS;
	ll T, M, N, res;
	FORA(M,1,100,1)
		cout<<euler_tot(M)<<"\n";
	return 0;
}
