Help me in solving LBJ201 problem

My issue

(A%2 == 0 && C%2 == 0)
(A%2 != 0 && C%2 != 0)
I do not understand this part of code why is used that

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 C = read.nextInt();
	        
	        if(A%2 == 0 && C%2 == 0){
	            int B = (A+C)/2;
	            System.out.println(B);
	        } else if (A%2 != 0 && C%2 != 0){
	            int B = (A+C)/2;
	            System.out.println(B);
	        } else {
	            System.out.println(-1);
	        }

	        
	    }
	}
}

Learning course: Java for problem solving - 1
Problem Link: CodeChef: Practical coding for everyone

@patrickones
Its is used to check whether both A and C are even or both are odd or not;
to get a valid integer average B both should be either even or odd means they must have same parity.