Олимпиадный тренинг

Задача 23334. Interesting numbers (C', C)


Задача

Темы:
Little Vasya loves numbers very much, and he especially loves interesting numbers. Vasya considers the number x interesting  if the sum of the squares of its digits is divisible by the number 7. For example, the number 123 -
interesting because 12 + 22 + 32 = 14 is divisible by 7, but 16 is not, because 12 + 62 = 37 is not divisible by 7. Once Vasya saw the number x on the blackboard, he immediately wanted to know the value of the minimum interesting number that is strictly greater than x.  Since Vasya is still too young, he turned to you for help in solving this problem.

Input data format
The input file contains a single integer x - the number written on the board 0<= x <= 105
 
Output data format
In a single line of the output file print the minimum interesting number that is strictly greater than x.
Enter Output
1 7
0 7
35 70