from itertools import product
provided_digits_str = "125678 01369 02347 012589"
provided_digits = [set(map(int, digits)) for digits in provided_digits_str.split()]
all_digits = set(range(10))
combinations = {i: [] for i in range(5)}
for combo in product(all_digits, repeat=4):
matched_positions = 0
for i, digit in enumerate(combo):
if digit in provided_digits[i]:
matched_positions += 1
if matched_positions == 4:
if all(combo[i] in provided_digits[i] for i in range(4)):
combinations[4].append("".join(map(str, combo)))
else:
combinations[matched_positions].append("".join(map(str, combo)))
for value, combo_list in combinations.items():
print(f"Value {value}:")
print(" ".join(combo_list))
print()