Help me in solving LBCV208A problem

My issue

i donot kn0w how to solve it

My code

// Step 1: Read and understand the problem statement and sample test cases

// Click on Next once you are ready to proceed.
#include<iostream>
using namespace std;

int main(){
    int T;
    int N,M;
    for(i  = 0;i<T,i++){
        if()
    }
}

Learning course: Beginner DSA in C++
Problem Link: CodeChef: Practical coding for everyone

@ayushijai24 The module is literally teaching you the logic and giving the code to solve.