Help me in solving LBCP01 problem

My issue

My code

// Update the program below to solve the problem

#include <stdio.h>

int main()
{
    int t;
    scanf("%d", &t); // Use scanf instead of cin in C

    while (t--)
    {
        int A, B, C;
        scanf("%d %d", &A, &C); //Use scanf instead of cin in C
        B=(A+C)/2;
        if(A>0 && B>0)
        {
            printf("%d\n",B);
        }
        else
        {
            printf("-1\n");
        }
    }

    return 0;
}

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

@greeshma020505
logic is not right
if both are even or both are odd then there would be valid average else it would be -1