logo AlgoBeat OnlineJudge
登录 注册

#209218. [SNCPC2019] 0689

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

We call a string as a 0689-string if this string only consists of digits 0, 6, 8 and 9. Given a 0689-string of length , one do the following operation exactly once: select a non-empty substring of and rotate it 180 degrees.

More formally, let be the -th character in string . After rotating the substring starting from and ending at 180 degrees (), string will become string of length extracted from the following equation, where indicates the -th character in string :

What's the number of different strings one can get after the operation?

输入格式

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first and only line contains a 0689-string ().

It's guaranteed that the sum of of all test cases will not exceed .

输出格式

For each test case output one line containing one integer, indicating the number of different strings one can get after applying the operation exactly once.

样例

样例输入 1

2
0689
08

样例输出 1

8
2

数据范围与提示

We hereby explain the first sample test case.

It's easy to discover that we can get different strings after the operation.