Pigeonhole principle

how (a-b)%m=a%m-b%m according to the video

this is a property of modulo (a-b)%m=(a%m-b%m+m)%m.
modulo is distributive over subtraction and we add +m just in case if after modulo a-b become negative but we want (a-b)%m=0 here so we can igonre the +m term and write (a-b)%m=a%m-b%m.

but to handle negative number we are taking modulo again??

you cannot take modulo of negative number so we add n to that negative number to make it positive then we take modulo