ISBN Validator

Contest 1

Every book published worldwide is assigned an ISBN-13 (International Standard Book Number). Bookstores, libraries, and online retailers use this 13-digit code to uniquely identify books in their inventory systems.

An ISBN-13 has the format:

The first 12 digits identify the book. The 13th digit is a check digit, calculated as follows:

1. Multiply each of the first 12 digits by alternating weights of and (first digit times , second digit times , third digit times , and so on).
2. Sum all 12 weighted values.
3. Compute the remainder when dividing the sum by .
4. If the remainder is , the check digit is . Otherwise, the check digit is minus the remainder.

Given a 13-digit ISBN string, determine if it is VALID or INVALID.

Then, regardless of whether it was valid, output the CORRECT check digit (the one computed by the algorithm above).

Input: A single line containing a 13-character string of digits.

Output: Two lines. The first line is VALID or INVALID. The second line is the correct check digit (a single digit -).
Constraints
Input is always exactly 13 digit characters (-).
Sample input
9780306406157
Sample output
VALID
7
Stdin