public static void main(String[] args) {
		int m=5, n=12;
		List<Integer> l=new ArrayList<>();
		int[][] b=new int[m][n];
		for (int i=1;i<=m*n;++i) l.add(i);
		Collections.shuffle(l);
		Iterator<Integer> iter= l.iterator();
		boolean parity=true;
		for (int i=0;i<m;++i) {
			for (int j=0;j<n;++j){
				if (parity) b[i][j]=iter.next().intValue();
				else b[i][n-j-1]=iter.next().intValue();
				
			}
			parity=!parity;
		}
				
		
		LongestSequence instance=new LongestSequence();
		int[] rel=instance.longestSequence(b);
		System.out.println(rel[0]-rel[1]);
	}