public static int longestConsecutive(int[][]b) {
		int m=b.length, n=b[0].length;
		int[][]t=new int[m][n];
		int[]x=new int[m*n], y=new int[m*n];
		for (int i=0;i<m;++i)
			for (int j=0;j<n;++j) {
				y[b[i][j]-1]=i;
				x[b[i][j]-1]=j;
			}
		int rel=0;
		for (int i=0;i<m*n;++i) {
			if (t[y[i]][x[i]]==0) {
				rel=Math.max(rel, lc_helper(b,y[i], x[i], 0, t));
			}
		}
		return rel;
	}