ll@(n,q,s,t,c); rep(q){ ll@u,@v; wt(min((v-u)%%n,(s-u)%%n+(v-t)%%n+c)); }