pd = [2, 3, 5, 7, 11, 13] cd = [4, 6, 8, 9, 10, 12] n, pn, cn = STDIN.gets.chomp.split.map{|x| Integer(x)} pattern = pd.repeated_combination(pn){|x| x}.product(cd.repeated_combination(cn){|x| x}).map{|x| x.flatten.sum} new_pattern = pattern.select{|x| x < n} pattern_num = pattern.size - new_pattern.size while new_pattern.size > 0 tmp = new_pattern.product(pattern).map{|x| x.sum}.select{|x| x < n} pattern_num += new_pattern.size - tmp.size new_pattern = tmp end puts pattern_num % 1000000007