$/=get.words;say ($0/($_=$1*(12+$3))+|0)*12+($0%$_,+^($3>(++$-$2)%12>=0)*$1+*...^0>=*)