
fun main(args:Array<String>):Unit {
    while (true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        println(calPattern(Array(n){readLine()!!.trim()}))
    }
}
fun calPattern(bytes:Array<String>, index:Int = 0, memo:Array<Long> = Array(bytes.size){-1L}):Long {
    if (index == bytes.size) return 1
    if (memo[index] >= 0) return memo[index]
    memo[index] = oneByteUnicodePattern(bytes[index]) * calPattern(bytes, index + 1, memo)
    if (bytes.size - index >= 2)
        memo[index] += twoByteUnicodePattern(bytes[index], bytes[index + 1]) * calPattern(bytes, index + 2, memo)
    if (bytes.size - index >= 3)
        memo[index] += threeByteUnicodePattern(bytes[index], bytes[index + 1], bytes[index + 2]) * calPattern(bytes, index + 3, memo)
    if (bytes.size - index >= 4)
        memo[index] += fourByteUnicodePattern(bytes[index], bytes[index + 1], bytes[index + 2], bytes[index + 3]) * calPattern(bytes, index + 4, memo)
    memo[index] = memo[index] % 1000000
    return memo[index]
}

fun oneByteUnicodePattern(byte:String):Long {
    val pattern = """^[0x]([01x]{7})""".toRegex()
    val matched = pattern.matchEntire(byte)
    return when(matched){
        null -> 0L
        else -> matched.groupValues[1].countXPattern()
    }
}
fun twoByteUnicodePattern(byte1:String, byte2:String):Long {
    val pattern1 = """^[1x]{2}[0x]([01x]{4})([01x])""".toRegex()
    val pattern2 = """^[1x][0x]([01x]{6})""".toRegex()
    val matched1 = pattern1.matchEntire(byte1)
    val matched2 = pattern2.matchEntire(byte2)
    return when{
        matched1 == null || matched2 == null -> 0L
        else -> {
            val x = matched1.groupValues[2] + matched2.groupValues[1]
            val y = matched1.groupValues[1]
            x.countXPattern() * y.countYPattern()
        }
    }
}
fun threeByteUnicodePattern(byte1:String, byte2:String, byte3:String):Long {
    val pattern1 = """^[1x]{3}[0x]([01x]{4})""".toRegex()
    val pattern2 = """^[1x][0x]([01x])([01x]{5})""".toRegex()
    val pattern3 = """^[1x][0x]([01x]{6})""".toRegex()
    val matched1 = pattern1.matchEntire(byte1)
    val matched2 = pattern2.matchEntire(byte2)
    val matched3 = pattern3.matchEntire(byte3)
    return when {
        matched1 == null || matched2 == null || matched3 == null -> 0L
        else -> {
            val x = matched2.groupValues[2] + matched3.groupValues[1]
            val y = matched1.groupValues[1] + matched2.groupValues[1]
            x.countXPattern() * y.countYPattern()
        }
    }
}
fun fourByteUnicodePattern(byte1:String, byte2:String, byte3:String, byte4:String):Long {
    val pattern1 = """^[1x]{4}[0x]([01x]{3})""".toRegex()
    val pattern2 = """^[1x][0x]([01x]{2})([01x]{4})""".toRegex()
    val pattern34 = """^[1x][0x]([01x]{6})""".toRegex()
    val matched1 = pattern1.matchEntire(byte1)
    val matched2 = pattern2.matchEntire(byte2)
    val matched3 = pattern34.matchEntire(byte3)
    val matched4 = pattern34.matchEntire(byte4)
    return when{
        matched1 == null || matched2 == null || matched3 == null || matched4 == null -> 0L
        else -> {
            val x = matched2.groupValues[2] + matched3.groupValues[1] + matched4.groupValues[1]
            val y = matched1.groupValues[1] + matched2.groupValues[1]
            x.countXPattern() * y.countYPattern()
        }
    }

}
fun String.countXPattern():Long {
    return 1L shl this.count{it == 'x'}
}
fun String.countYPattern():Long {
    return when{
        this.contains('1') -> 1L shl this.count{it == 'x'}
        else -> (1L shl this.count{it == 'x'}) - 1
    }
}
