#K81082. Stepping Numbers

    ID: 35674 Type: Default 1000ms 256MiB

Stepping Numbers

Stepping Numbers

A Stepping Number is a number in which every adjacent pair of digits has an absolute difference of exactly 1. In other words, for a number with digits \(d_1,d_2,\dots,d_k\), it is a Stepping Number if and only if \(|d_i-d_{i+1}|=1\) for every \(1 \le i < k\). Note that any single-digit number is considered a Stepping Number.

Your task is to determine whether a given number is a Stepping Number. For each test case, output "YES" if the number is a Stepping Number or "NO" if it is not.

inputFormat

The first line contains an integer (T) denoting the number of test cases. Each of the following (T) lines contains a single integer (n).

outputFormat

For each test case, print a single line containing either "YES" if (n) is a Stepping Number, or "NO" otherwise.## sample

3
123
121
122
YES

YES NO

</p>