Robot collects points WA

I am not able to figure out where I am getting wrong in this question

#include<bits/stdc++.h>
using namespace std;
int ans=0;

void fun(int row,int col,int a[][5],int sum,int n){
if(row==n){
ans=max(ans,sum);
return ;

}
if(col<0 or col>=n)return;
if(row!=-1)
sum+=a[row][col];
fun(row+1,col,a,sum,n);
fun(row+1,col-1,a,sum,n);
fun(row+1,col+1,a,sum,n);

return ;

}

int main() {
int t;
cin>>t;
while(t–){
int h;
cin>>h;
int a[h][5];
for(int i=h-1;i>=0;i–)
for(int j=0;j<5;j++)cin>>a[i][j];

	int temp[h][5];

	for(int i=0;i<h-4;i++){
        for(int j=0;j<h;j++)
		for(int r=0;r<5;r++)
		temp[j][r]=a[j][r];

		for(int row=0;row<5;row++)
		for(int j=0;j<5;j++)
		if((i+row)<h and temp[i+row][j]==-1){
		temp[i+row][j]=0;}


		//  for(int j=0;j<h;j++){
		// for(int r=0;r<5;r++)cout<<temp[j][r]<<" ";
		// cout<<"\n";
		// }
         
		 
	    fun(-1,2,temp,0,h);


	}
	cout<<ans<<endl;
	ans=0;

}

return 0;

}