Help me with the problem make jumps. MKJUMPS

//for one test case only
#include<bits/stdc++.h>
using namespace std;
int n;
int totalCells=0;
vector<pair<int,int>> vect(n);
int globalTotal;
int dx[]={2,2,-1,1,-2,-2,-1,1};
int dy[]={-1,1,2,2,1,-1,-2,-2};
bool valid(int x,int y,vector<vector> &trace,vector<vector> &board,int n){
if(x<0||x>=n||y<vect[x].first||y>vect[x].first+vect[x].second-1||trace[x][y]==2||trace[x][y]==0) return false;
return true;
}
void moves(int total,vector<vector> &board,vector<vector> &trace,int x,int y,int n){
if(total>globalTotal){
globalTotal=max(globalTotal,total);
}
for(int i=0;i<8;i++){
int newX=x+dx[i];
int newY=y+dx[i];
if(valid(newX,newY,trace,board,n)){
trace[x][y]=2; //store 2 for marking that it has been visited already
moves(total+1,board,trace,newX,newY,n);
total-=1;
trace[x][y]=1;
}
}

return;

}
void solve(vector<pair<int,int>> &vect){
int n=vect.size();
vector<vector> board(10,vector(10,0));
for(int i=0;i<n;i++){
for(int j=vect[i].first;j<vect[i].second+vect[i].first;j++) board[i][j]=1;
}
int start;
for(int i=0;i<10;i++){
if(board[0][i]==1){
start=i;
break;
}
}
vector<vector> trace=board;
int total=0;
moves(total,board,trace,0,start,n);
cout<<globalTotal<<endl;
}
int main(){

cin>>n;

for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    vect.push_back(make_pair(a,b));
    totalCells+=b;
}
solve(vect);

}

i am getting wrong answer
the globalTotal variable should store the total places we can make jumps to
but it is not giving correct ans

@ankesh_chaubey
can u send the problem link?