Problem:


新薬開発

英世博士は日々研究を行い、新しい薬を開発しようとしています。新薬を開発するためには、色々な物質を組み合わせて薬を作り試験を行い、良い薬を見つけなければなりません。様々な組み合わせを試していくうちに、英世博士は物質の組み合わせが樹形図で表せることを突き止めました。

右の図は、薬の調合を表す樹形図の例です。図の中で丸く囲まれたものを物質ノード、三角で囲まれたものを選択ノードと呼びます。物質ノードは物質を表します。選択ノードは、物質の選択を表すもので、それ自体は物質を表しません。選択ノードには or 型（&or;が付いたもの）と alt 型（&hArr;が付いたもの）の２種類があります。また ? が付いたノードは、それがオプションであることを表します。ただし、選択ノードの子ノード（下向きの枝の先にあるノード）がオプションになることはありません。樹形図に現れる異なる物質ノードは、それぞれ別の物質を表すものとします。

薬の調合を行うときは、樹形図の一番上のノードからはじめて、順々にノードをたどっていきながら以下のようにしてノードを選んでいきます。

 たどり着いたノードがオプションでない物質ノードなら、それを必ず選ぶ。

 オプションの物質ノードなら、それを選ぶかどうかは任意。

 or 型の選択ノードなら、その子から少なくとも一つを選ぶ。ただし、その選択ノードがオプションなら、子を一つも選ばなくてもよい。

 alt 型の選択ノードなら、その子から一つだけを選ぶ。ただし、その選択ノードがオプションなら、子を選ばなくてもよい。

あるノードが選ばれたときだけ、そのノードから下に向かう枝をそれぞれたどっていきます。選ばれなければ、それらをたどることはありません。

あなたは英世博士から、薬の物質の組み合わせを表す樹形図を受け取り、組み合わせの数が全部で何通りあるか求めるよう指示されました。樹形図が与えられたとき、組み合わせの総数を出力するプログラムを作成してください。

入力

入力は以下の形式で与えられる。

N
node1
node2
:
nodeN
s1 t1
s2 t2
:
sN-1 tN-1

１行目にノードの数 N (1 ≤ N ≤ 1000) が与えられる。続く N 行に、i 番目のノードの情報 nodei が与えられる。１番目のノードを樹形図の一番上のノードとする。続く N-1 行に si 番目のノードからその子である ti 番目のノード (1 ≤ si &ne; ti ≤ N) へ向かう枝が与えられる。t1 から tN-1 までには、2 から N までの数が一度だけ現れる。

ノードの情報は以下の形式である。

 E      オプションでない物質ノード。

 E?      オプションである物質ノード。

 type      オプションでない選択ノード。type は A か R のいずれかで、A は alt型、R は or 型を表す。

 type?      オプションである選択ノード。type の形式は同上。

入力から得られる樹形図は、以下の条件を満たす。

 選択ノードは２つ以上の子ノードを持つ。

 選択ノードの子ノードはオプションでない。

 樹形図の一番上のノードはオプションでない。

 どのノードについても、子ノードの数は 10 を超えない。

出力

与えられた樹形図から得られるすべての組み合わせの総数を１行に出力する。ただし、出力すべき値は非常に大きくなりうるので、代わりに 1,000,000,007 で割った余りを出力する。

入出力例

入力例１ 

12
A
E
E
E
R?
E?
E?
E
E
E
E?
E
1 2
1 3
1 4
2 5
4 6
4 7
5 8
5 9
7 10
7 11
11 12

出力例１

11

入力例２

10
E
R?
E
R
E
E
A
E
E
E
1 2
1 7
2 3
2 4
4 5
4 6
7 8
7 9
7 10

 出力例２

24



Sample input:
12
A
E
E
E
R?
E?
E?
E
E
E
E?
E
1 2
1 3
1 4
2 5
4 6
4 7
5 8
5 9
7 10
7 11
11 12


Sample output:
11

Submission status: Wrong Answer

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    edges = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        edges.append(tuple([int(x) for x in input().split()]))
    for (i, j) in edges:
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % 1000000007)

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''
        if "E" in self.kind:
            result = 1
            for child in self.children:
                result *= child.number_of_cases()
            if "?" in self.kind:
                result += 1
            return result

        elif "A" in self.kind:
            result = sum([child.number_of_cases() for child in self.children])
            if "?" in self.kind:
                result += 1
            return result

        elif "R" in self.kind:
            cases = [2*child.number_of_cases() for child in self.children]
            result = sum(cases) - 1
            if "?" in self.kind:
                result += 1
            return result

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])
        nodes[i-1].index.append(j-1)

    print(reduce_to_top(nodes).n % N)

def product(iterator):
    '''product for iterator
    '''
    result = 1
    for element in iterator:
        result *= element % N
        result %= N
    return result

def step_reducing(nodes):
    last_parents = [node for node in nodes if node is not None and node.is_last_parent()]
    for parent in last_parents:
        parent.n = parent.number_of_cases()
        parent.children = list()
        for i in parent.index:
            nodes[i] = None
    return nodes

def reduce_to_top(nodes):
    while nodes[1:] != [None]*(len(nodes)-1):
        nodes = step_reducing(nodes)
    return nodes[0]


class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None, n=None, index=None):
        self.kind = kind
        if children is None:
            children = list()
        if index is None:
            index = list()
        self.children = children
        self.index = index
        self.n = None

    def number_of_cases(self):
        ''' calc the number of cases.
        '''
        if self.n is not None:
            return self.n

        cases = self.generate_cases()
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product((x+1 for x in cases))
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

    def generate_cases(self):
        '''generate cases
        '''
        for child in self.children:
            yield child.number_of_cases()

    def is_last_parent(self):
        bools = [child.children == [] for child in self.children]
        return bools and all(bools)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])
        nodes[i-1].index.append(j-1)

    print(reduce_to_top(nodes).n % N)


def product(iterator):
    result = 1
    for element in iterator:
        result *= element % N
        result %= N
    return result


def step_reducing(nodes):
    last_parents = [node for node in nodes if node is not None and node.is_last_parent()]
    for parent in last_parents:
        parent.n = parent.number_of_cases()
        parent.children = list()
        for i in parent.index:
            nodes[i] = None
    return nodes


def reduce_to_top(nodes):
    while nodes[1:] != [None]*(len(nodes)-1):
        nodes = step_reducing(nodes)
    return nodes[0]


class Node:

    def __init__(self, kind, children=None, n=None, index=None):
        self.kind = kind
        if children is None:
            children = list()
        if index is None:
            index = list()
        self.children = children
        self.index = index
        self.n = n

    def number_of_cases(self):
        if self.n is not None:
            return self.n

        cases = self.generate_cases()
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product((x+1 for x in cases))
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

    def generate_cases(self):
        for child in self.children:
            yield child.number_of_cases()

    def is_last_parent(self):
        bools = [child.children == [] for child in self.children]
        return bools and all(bools)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
m = 1000000007

from sys import stdin
f_i = stdin

N = int(f_i.readline())

n_type = [''] * N
for i in range(N):
    t = f_i.readline().rstrip()
    n_type[i] = t

adj = [[] for i in range(N)]
for i in range(N - 1):
    s, t = map(int, f_i.readline().split())
    s -= 1
    t -= 1
    adj[s].append(t)

from itertools import combinations

def prod(nums):
    p = 1
    for n in nums:
        p *= n
    return p

import sys
sys.setrecursionlimit(4000)

def dfs(node):
    nt = n_type[node]
    chld = adj[node]
    if nt == 'E':
        if chld:
            return prod(map(dfs, chld)) % m
        else:
            return 1
    elif nt == 'E?':
        if chld:
            return (prod(map(dfs, chld)) + 1) % m
        else:
            return 2
    elif nt == 'A':
        return sum(map(dfs, chld)) % m
    elif nt == 'A?':
        return (sum(map(dfs, chld)) + 1) % m
    else:
        cnt = 0
        c_s = tuple(map(dfs, chld))
        for i in range(1, len(chld) + 1):
            for vals in combinations(c_s, i):
                cnt += prod(vals)
        if len(nt) == 1:
            return cnt % m
        else:
            return (cnt + 1) % m

print(dfs(0))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
N = int(input())
ND = ["E", "E?", "A", "R", "A?", "R?"]
T = [input() for i in range(N)]
G = [[] for i in range(N)]
for i in range(N-1):
    s, t = map(int, input().split())
    G[s-1].append(t-1)
MOD = 10**9 + 7
def dfs(v):
    t = T[v]
    if t[0] in ['E', 'R']:
        r = 1
    else:
        r = 0
    t0 = t[0]
    for w in G[v]:
        x = dfs(w)
        if t0 == 'E':
            r = r * x % MOD
        elif t0 == 'R':
            r = r * (x+1) % MOD
        else:
            r += x
    if t[0] == 'R':
        r -= 1
    if t[-1] == '?':
        r += 1
    return r % MOD
print(dfs(0))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)
mod = 1000000007
n = int(input())
nodes = [input() for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n - 1):
  s, t = map(int, input().split())
  s -= 1
  t -= 1
  edges[s].append(t)

def score(index):
  node = nodes[index]
  if node[0] == "E":
    ret = 1
    for to in edges[index]:
      ret *= score(to)

  if node[0] == "A":
    ret = 0
    for to in edges[index]:
      ret += score(to)

  if node[0] == "R":
    ret = 1
    for to in edges[index]:
      ret *= (score(to) + 1)
    ret -= 1

  if node[-1] == "?":
    ret += 1

  return ret % mod

print(score(0))

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    edges = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        edges.append(tuple([int(x) for x in input().split()]))
    for (i, j) in edges:
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % 1000000007)

def product(lis):
    result = 1
    for element in lis:
        result *= element
    return result

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result

        elif "R" in self.kind:
            result = product(map(lambda x: x+1, cases))
            if "?" not in self.kind:
                result -= 1
            return result

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    edges = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        edges.append(tuple([int(x) for x in input().split()]))
    for (i, j) in edges:
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(lis):
    result = 1
    for element in lis:
        result *= element
    return result

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product(map(lambda x: x+1, cases))
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    edges = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        edges.append(tuple([int(x) for x in input().split()]))
    for (i, j) in edges:
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(lis):
    result = 1
    for element in lis:
        result *= element % N
    return result

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product(map(lambda x: x+1, cases))
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(lis):
    '''product for list
    '''
    result = 1
    for element in lis:
        result *= element % N
    return result

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product([x+1 for x in cases])
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(lis):
    '''product for list
    '''
    result = 1
    for element in lis:
        result *= element % N
        result %= N
    return result

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product([x+1 for x in cases])
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

import sys
from math import log10

N = 1000000007
LOGN = 9

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(lis):
    '''product for list
    '''
    result = 1
    for element in lis:
        if log10(result) + log10(element) > 9:
            result = ((result-N) * (element-N)) % N
        else:
            result *= element % N
            result %= N
    return result

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product([x+1 for x in cases])
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

from math import log10

N = 1000000007
LOGN = 9

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(lis):
    '''product for list
    '''
    result = 1
    for element in lis:
        if log10(result) + log10(element) > LOGN:
            if log10(result) > LOGN-4:
                result = result-N
            if log10(element) > LOGN-4:
                element = element-N

        result *= element % N
        result %= N
    return result

class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product([x+1 for x in cases])
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(lis):
    '''product for list
    '''
    result = 1
    for element in lis:
        result *= element % N
        result %= N
    return result


class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''

        cases = [child.number_of_cases() for child in self.children]
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product([x+1 for x in cases])
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])

    print(nodes[0].number_of_cases() % N)

def product(iterator):
    '''product for iterator
    '''
    result = 1
    for element in iterator:
        result *= element % N
        result %= N
    return result


class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None):
        self.kind = kind
        if children is None:
            children = list()
        self.children = children

    def number_of_cases(self):
        ''' calc the number of cases.
        '''
        cases = self.generate_cases()
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product((x+1 for x in cases))
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

    def generate_cases(self):
        '''generate cases
        '''
        for child in self.children:
            yield child.number_of_cases()

if __name__ == '__main__':
    main()