protected void check(int color, int i, int j ){        
      if(closable(i,j)){
        if( (values[i][j] & LEFT)==0 ){
            values[i][j] |= LEFT;
            values[i][j-1] |= RIGHT;
            values[i][j] |= color;
            check(color, i,j-1);
        }

        if( (values[i][j] & TOP)==0 ){
            values[i][j] |= TOP;
            values[i-1][j] |= BOTTOM;
            values[i][j] |= color;
            check(color, i-1,j);
        }
        
        if( (values[i][j] & RIGHT)==0 ){
            values[i][j] |= RIGHT;
            values[i][j+1] |= LEFT;
            values[i][j] |= color;
            check(color, i,j+1);
        }

        if( (values[i][j] & BOTTOM)==0 ){
            values[i][j] |= BOTTOM;
            values[i+1][j] |= TOP;
            values[i][j] |= color;
            check(color, i+1,j);
        }        
      }  
    }