lines = ARGF.read.split("\n")
part1 = part2 = 0
lines.each do |line|
theirs = line[0].ord - 'A'.ord
ours = line[2].ord - 'X'.ord
part1 += ours + (ours - theirs + 1) % 3 * 3 + 1
part2 += ours * 3 + (theirs + ours - 1) % 3 + 1
end
puts part1, part2