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.
# HEY STALKER
def get_mod(num):
    res = 0
    for i in range(0, len(num)):
        if num[i] != -1:
            res = ((res * 10 + num[i]) % 7)
    return res
d = {0: 896, 1: 869, 2: 968, 3: 689, 5: 698, 6: 986, 4: 816}
l = list(map(int, input()))
dx = [0 for t in range(10)]
ch = [6, 8, 9]
for t in range(len(l)):
    if l[t] == 1:
        l[0], l[t] = l[t], l[0]
        break
f = 0
for t in range(len(l)):
    if f == 3:
        break
    if l[t] in ch and dx[l[t]] == 0:
        dx[l[t]] = 1
        l[t] = -1
        f += 1
z = get_mod(l)
if z != 4:
    for t in range(len(l)):
        if l[t] != -1:
            print(l[t], end="")
    print(d[z])
else:
    dx1 = [0 for t in range(10)]
    ch1 = [6, 8, 1]
    for t in range(len(l)):
        if l[t] == 9:
            l[0], l[t] = l[t], l[0]
            break
    ff = 0
    for t in range(len(l)):
        if ff == 3:
            break
        if l[t] in ch1 and dx1[l[t]] == 0:
            dx1[l[t]] = 1
            l[t] = -1
            ff += 1
    z = get_mod(l)
    for t in range(len(l)):
        if l[t] != -1:
            print(l[t], end="")
    print(d[z])