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