FANCY - FANCY NUMBERS


Girls usually give only missed calls to their boyfriends and they want them to call back. These boys are now busy with their engineering subjects and cannot remember all girl friends’ mobile number. Because of this, girls make it easy for them by having fancy mobile numbers. A fancy mobile number may contain many continuous digits in it.

For example 9994442200 is a fancy mobile number because the boy can remember simply as triple nine, triple four, double two and double zero. As they are engineering students they do think different. One of the engineering students can spell the above number as double nine, nine, four, double four, two, two, double zero.

The number 100 has only 2 possibilities as it can be spelt as either one, zero, zero (or) one, double zero.

Given a mobile number find the number of possibilities that the number can be remembered.

Input

The first line consists of an integer t denoting the number of test cases. Each test case consists of a mobile number of length <= 30 digits.

Output

For each test case output the number of possibilities the number can be remembered.

Constraints

1 <= t <= 100000

Example

Input:
3
100
12345
11112

Output:
2
1
8

WARNING: Huge data set! Make your I/O optimizations.


hide comments
ritik_agr: 2016-06-25 15:19:45

@vineetpratik got AC using string ,cin,cout

suraj: 2016-06-22 12:33:27

accepted with use of cin and cout and string

vineetpratik: 2016-06-19 15:27:55

used string , cin ,cout got "SIGSEGV" error.
then used scanf,printf,character array and got accepted!
phew!

rayhan50001: 2016-05-01 22:58:59

use long long cost me 1 WA... xD

Shubham Khandelwal: 2016-02-22 20:28:53

My 100th

minhthai: 2016-01-25 16:52:54

keep getting Runtime Error NZEC in java :((

dark_lord1: 2015-12-27 01:14:52

Simple one.. AC in one go..used simple C and no I/O optimizations

asshole: 2015-12-26 13:27:36

run time error with python2.7 ..works fine on ideone and etc
help me out

Ravi Chandra: 2015-09-22 19:14:30

Easy one go:)

gullu_mishra: 2015-09-16 16:53:50

simple [spoiler removed].....AC in 1 go ... 37th in spoj ... ong way to gooooooo.. :)

Last edit: 2015-10-12 14:26:00

Added by:cegprakash
Date:2011-12-26
Time limit:0.802s-1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64