Function to calculate the number of valid assignments
static int noOfAssignments ( String s , int n , int i , int c_x , int c_y ) { if ( F [ i , c_x , c_y ] != - 1 ) return F [ i , c_x , c_y ] ; if ( i == n ) {