Help me in solving BMJ18 problem

My issue

Alice is playing Air Hockey with Bob.
The first person to earn seven points wins the match.
Currently, Alice’s score is

A and Bob’s score is

B.

Charlie is eagerly waiting for his turn. Help Charlie by calculating the minimum number of points that will be further scored in the match before it ends

My code

import java.util.Scanner;

class Codechef
{
	public static void main (String[] args)
	{
		Scanner read = new Scanner(System.in);
		
		int t = read.nextInt();
		for(int i=0; i<t; i++)
		{
    		int a = read.nextInt();
    		int b = read.nextInt();
    		// Update your code below this line to solve the problem
            
		}
	}
}

Learning course: Solve Programming problems using Java
Problem Link: Review problem - 1 Practice Problem in Solve Programming problems using Java - CodeChef

@ies_n_0128
plzz refer the following solution

import java.util.Scanner;

class Codechef
{
	public static void main (String[] args)
	{
		Scanner read = new Scanner(System.in);
		
		int t = read.nextInt();
		for(int i=0; i<t; i++)
		{
    		int a = read.nextInt();
    		int b = read.nextInt();
    		// Update your code below this line to solve the problem
    	   System.out.println(7-Math.max(a,b));
		}
	}
}