def solve_it(input_data):
    # parse the input
    lines = input_data.split('\n')

    parts = lines[0].split()
    item_count = int(parts[0])
    set_count = int(parts[1])
    
    sets = []
    for i in range(1, set_count+1):
        parts = lines[i].split()
        sets.append(Set(i-1, float(parts[0]), map(int, parts[1:])))

    # generate MiniZinc data file
    data_file = "data.dzn"
    generateMinizincDataFile(item_count, set_count, sets, data_file)

    # specify here how many solutions the solver should maximally search for ('0' means all)
    nb_solutions = 10

    # solve with Minizinc's MIP solver (CBC of COIN-OR)
    process = Popen(['mzn-g12mip', '-n', str(nb_solutions),'setCovering.mzn', 'data.dzn'],
                    stdout=PIPE, stderr=PIPE)
    # ALTERNATIVE_1: solve with Minizinc's CP solver
    # process = Popen(['mzn-g12fd', '-n', str(nb_solutions),'setCovering.mzn', 'data.dzn'],
    #                stdout=PIPE, stderr=PIPE)
    # ALTERNATIVE_2: solve with Minizinc's CP solver that uses learning via lazy clause generation
    # process = Popen(['mzn-g12lazy', '-n', str(nb_solutions),'setCovering.mzn', 'data.dzn'],
    #                stdout=PIPE, stderr=PIPE)
    # ALTERNATIVE_3: solve with CP solver Gecode (however, Gecode must be installed to do that!)
    # process = Popen(['mzn-gecode', '-n', str(nb_solutions),'setCovering.mzn', 'data.dzn'],
    #                stdout=PIPE, stderr=PIPE)

    (stdout, stderr) = process.communicate()

    # print error messages if there are any 
    print stderr
    # extract the solution from standard-out
    solution = extractSolution(stdout,set_count)

    # calculate the cost of the solution
    obj = sum([s.cost*solution[s.index] for s in sets])

    # prepare the solution in the specified output format
    output_data = str(obj) + ' ' + str(1) + '\n'
    output_data += ' '.join(map(str, solution))

    return output_data


# ##################################################################################
dataset/ETHPy150Open discreteoptimization/setcover/minizinc_001/solver.py/solve_it/original