Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String [] args)
  7.     {
  8.         int test,i;
  9.         BigInteger a,b,result;
  10.      
  11.         Scanner sc = new Scanner(System.in);
  12.         test = sc.nextInt();
  13.      
  14.         for(i=1; i<=test ;i++)
  15.         {
  16.             a=sc.nextBigInteger();
  17.             b=sc.nextBigInteger();
  18.          
  19.             result = b.remainder(a);
  20.          
  21.             System.out.println(""+result);
  22.         }
  23.      
  24.     }
  25. }