def scan; gets.split.map(&:to_i); end @dp={} def guchoku216(aa,turn=true) return !turn if aa.size == 0 aa.sort! return @dp[aa+[turn]] if @dp[aa+[turn]] aa.each_index{|i| ac = aa.clone ac[i]-=1 3.times{ break if ac[i] <= 0 return @dp[aa+[turn]] = turn if (guchoku216(ac.clone,!turn) == turn) ac[i]-=1 } ac.delete(0) return @dp[aa+[turn]] = turn if (guchoku216(ac.clone,!turn) == turn) } return @dp[aa+[turn]] = !turn end nn = scan.map{|e|e%6} nn.delete(0) puts guchoku216(nn) ? "Taro" : "Jiro"