SPOJ BYTESM2 : JAVA RUNTIME ERROR (NZEC)

I am using simple DP , cant find the reason for NZEC error.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class BYTESM2 {
	private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private static final PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		int t=Integer.parseInt(br.readLine());
		StringTokenizer inp;
		int maxSum=0,H,W;
		while(t-->0)
			{
				inp=new StringTokenizer(br.readLine());
				H=Integer.parseInt(inp.nextToken());
				W=Integer.parseInt(inp.nextToken());
				int arr[][]=new int[H+1][W+2];
				maxSum=0;
				for(int i=1;i<H+1;i++) {
					inp=new StringTokenizer(br.readLine());
					for(int j=1;j<W+1;j++) {
						 arr[i][j]=Integer.parseInt(inp.nextToken())+Math.max(arr[i-1][j-1], Math.max(arr[i-1][j], arr[i-1][j+1]));
						 if(i==H && arr[i][j]>maxSum)maxSum=arr[i][j];
					}
				}
				pw.println(maxSum);
			}
		pw.close();
	}
}