There is a mistake in API introduction.
if first, padding mask should be 0, and if last, padding mask should be -1.