print("Inserire le righe per verificare la validità del sudoku")

S = []

for i in range(9):
    riga = input("Inserire riga: ")
    riga_n = [int(c) for c in riga]
    S.append(riga_n)

status = True

for j in range(9):
    riga = S[j]
    for n in range(1, 10):
        if n not in riga:
            status = False

for k in range(9):
    colonna = [S[r][k] for r in range(9)]
    for n in range(1, 10):
        if n not in colonna:
            status = False

for r in range(0, 9, 3):
    for c in range(0, 9, 3):
        quadrato = [S[r+dr][c+dc] for dr in range(3) for dc in range(3)]
        for n in range(1, 10):
            if n not in quadrato:
                status = False

if status == True:
    print("Si")
else:
    print("No")