# frozen_string_literal: true X = gets.chomp.chars.map(&:to_i) .sort.permutation.to_a.uniq.reject { |i| i[0].zero? }.reverse[1] puts(X.nil? ? -1 : X.join)