You are analyzing a string literal written in the C programming language. In C, special characters inside string literals are represented using escape sequences, all of which begin with a backslash (\).
Some relevant escape sequences are:
You are given a string $$$S$$$, which represents the characters written inside the quotation marks of a C string literal. The string $$$S$$$ consists only of two characters: backslash (\) and zero (0).
Your task is to determine the value that the C function strlen would return after interpreting all escape sequences in $$$S$$$. If $$$S$$$ contains an incomplete escape sequence (i.e., a single backslash at the end of the string), then $$$S$$$ is considered INVALID, and you should report that instead.
The string $$$S$$$ is scanned from left to right according to the following rules:
The first line contains a single integer $$$T \: (1 \le T \le 10^5)$$$ — the number of test cases.
Each test case consists of a single string $$$S \: (1 \le |S| \le 10^5)$$$, containing the characters \ and 0 — the string literal inside the quotation marks passed as a parameter to strlen.
It is guaranteed that the sum of $$$|S|$$$ over all test cases does not exceed $$$10^6$$$.
For each test case, output a single integer in a line — the value returned by strlen after decoding the string. If the string is not valid, output INVALID instead. Note that the output is case-sensitive.
4 \\\\ \\0 \0\\00 \\\
2 2 0 INVALID
In the first test case, \\\\ decodes to \\, so the length is $$$2$$$. In the second test case, \\ 0 decodes to \ followed by 0, so the length is $$$2$$$. In the third test case, \ 0\\ 00 begins with a NUL character, so strlen returns $$$0$$$. In the fourth test case, \\\ ends with an incomplete escape sequence, so it is INVALID.
| Name |
|---|


