copiled match3 pascal implementation