($d,$d,$t)=glob<>;push@{$m{$_%$d}},($_+1e9)/$d|0for glob<>;for(values%m){$b=-1e9;$b<$_+$t?($\+=$_+$t-($b<$_-$t?$_-$t:$b+1)+1,$b=$_+$t):0for sort{$a-$b}@$_}print