You know, there are more and more LED Displays used for show numbers in everywhere, a general product is like the left picture below, called as 7 segments LED, because it can show all the digitals from 0 to 9 with 7 segments as the right picture below.


There are many 7 segment LED displays in our restraint, so we can view the money left in our sunny card. Unfortunately, some displays always with one or more segment are broken, that means, the segment which should be light up when it display a digital can't work. For example, if the 'a' segment is broken, then '7' and '1' will be displayed as '1' either. 
Now, Bob who is standing on front of a broken LED display want to know, how many possible results would be the number on the display. For example, with a LED display which it's all 'a' segments were broken, "11" would be 4 possible results which are "11", "17", "71" and "77". Note that pre-zeros are valid, for example, "0001" is equal to "1" or "01". 

Input

There are multiply test cases, every case start with a single integers N in the first line, that is how many LED in this case, the second line is a string shows which segment is broken in the LED from 'a' to 'g', good segment will replace as '-', the follow N lines will hold a string in each line to show numbers from left to right, which shows the lighted segment in the i-th LED. (1 <= N <= 9) 
Input will end with a single line which N == -1.

Output

For each test case, output an integer that how many possible numbers should be the LEDs described by the input in a single line.

Sample Input

2 
a------ 
--c--f- 
--c--f- 
-1 

Sample Output

Case 1: 4

题意:给你一个模式串,表示a~g哪个灯坏了

然后再给你n个串表示当前亮着的灯,

一个穿表示一位数 

比如

--c--f-

--c--f-

表示 11

让你求这个数可能有几种情况表示

思路,枚举每一个数字,让它该坏的灯管坏掉 然后与输入的串比较

如果对比成功那么这一位的个数+1,最后的结果是每一位的数的乘积

详见代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define ll long long
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=1e5+5;
char vis[10][10] = {
	"abc-efg", "--c--f-", "a-cde-g", "a-cd-fg",
	"-bcd-f-", "ab-d-fg", "ab-defg", "a-c--f-",
	"abcdefg", "abcd-fg"
};
char DLGD[20],LGD[20];
ll cnt[20];
int main()
{
    int n,t=1;
    while(~scanf("%d",&n))
    {
        if(n==-1)break;
        scanf("%s",DLGD);
        ll ans=1;
        for(int i=1;i<=n;i++)
        {
            scanf("%s",LGD);
            ll cnt=0;
            for(int i=0;i<10;i++)
            {
                char s[20];
                strcpy(s,vis[i]);
                for(int j=0;j<7;j++)
                {
                    if(DLGD[j]!='-')
                        s[j]='-';
                }
                if(strcmp(s,LGD)==0)
                    cnt++;
            }
            if(cnt)ans*=cnt;
        }
        printf("Case %d: %lld\n",t++,ans);
    }
    return 0;
}