Help me in solving PMD7 problem

My issue

why we have to perform this operation
int l=m%4;
if(l==0 && m!=0)
{
l=4;
}

My code

#include <stdio.h>
#include<math.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--){
	    long long int x,m,a,nn=0, v;
	    scanf("%lld%lld",&x,&m);
	    for(int i=x;i>0;i/=10){
	        a=i%10;
	        int l=m%4;
           if(l==0 && m!=0)
           {
               l=4;
           }
	        v=pow(a,l);
	       
	        if(v<10)
	        nn=nn*10+v;
	        else
	        {
	            nn=nn*10+(v%10);
	            
	        }
	    }
	        if(nn%7==0)
	        printf("YES\n");
	        else
	        printf("NO\n");
	    
	}
	return 0;
}


Problem Link: CodeChef: Practical coding for everyone