/ruby_interactive@mmis_js_bottarget = (0..9).to_a.shuffle.shift(4).map(&:to_s)
STDOUT.sync = true
loop do
begin
line = readline.chomp
rescue EOFError
puts "Quit : P"
exit
end
next unless line =~ /^\d{4}$/
next unless line.chars.uniq.length == line.length
cross = line.chars & target
a, b = 0, 0
puts "%dA%dB" % ( a, b = cross.partition { |c| target.index(c) == line.index(c) }.map(&:length))
break if a == 4
end
puts "Finish! 💐"