Driver code
public static void main ( String [ ] args ) { n = 2 ; m = 2 ; int b [ ] [ ] = { { 1 , 4 } , { 2 , 4 } } ; int c [ ] [ ] = { { 3 , 2 } , { 3 , 1 } } ; for ( int i = 0 ; i < MAXI ; i ++ ) { for ( int j = 0 ; j < MAXI ; j ++ ) { for ( int k = 0 ; k < MAXI * MAXI ; k ++ ) { dp [ i ] [ j ] [ k ] = - 1 ; } } }