#include <stdio.h>

char mot[5][33]={"","0xxxxxxx","110yyyyx10xxxxxx","1110yyyy10yxxxxx10xxxxxx","11110yyy10yyxxxx10xxxxxx10xxxxxx"};
int main(void){
  int n,i;
  scanf("%d",&n);
  while(n!=0){
    int ans=1,fl=0;
    char sh=0;
    //sh...1が有ったらtrue
    //fl...xが
    char s[33];
    for(i=0;i<n;i++){
      scanf("%s",s+i*8);
    }
    for(i=0;i<n*8;i++){
      if(mot[n][i]=='0' || mot[n][i]=='1'){
	if(mot[n][i]!=s[i] && s[i]!='x'){
	  ans=0;
	  goto fin;
	}
      }
    }
    //31
    //778240=2^12*95
    for(i=0;i<n*8;i++){
      if(mot[n][i]=='y'){
	if(s[i]=='x'){
	  fl=1;ans*=2;
	  ans%=1000000;
	}
	else{
	  sh+=s[i]-48;
	}
      }
    }
    if(n!=1){
      if(sh==0){
	if(fl==0){
	  ans=0;
	  goto fin;
	}
	else ans--;
      }
    }

    for(i=0;i<n*8;i++){
      if(mot[n][i]=='x'){
	if(s[i]=='x')ans*=2;
	ans%=1000000;
      }
    }
  fin:
    printf("%d\n",ans%=1000000);
    scanf("%d",&n);
  }
  return 0;
}