One test case not passing

One of the test case isn’t passing. I am getting a run-time error. What is the mistake?
link: https://ide.codingblocks.com/s/212479

You interchanged the rows and columns and that termination condition on j was incorrect. PLease make these changes.
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
cin>>arr[i][j];
}
}
int key;
cin>>key;
int i=0,j=m-1;
bool isPresent = false;
while(i<n&&j>=0)