import java.util.HashSet; import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 int x = 0; int y = 0; HashSet<Character> set = new HashSet<>(); set.add('A'); set.add('D'); set.add('W'); set.add('S'); while (in.hasNextLine()) { // 注意 while 处理多个 case // int a = in.nextInt(); // int b = in.nextInt(); // System.out.println(a + b); String s = in.nextLine(); String[] ss = s.split(";"); for (int i=0;i<ss.length;i++) { String word = ss[i].trim(); if ("".equals(word)) { continue; } char c = word.charAt(0); if (!set.contains(c)) { continue; } if (!word.substring(1).chars().allMatch(Character::isDigit)) { continue; } int steps = Integer.parseInt(word.substring(1)); if (steps < 1 || steps > 99) { continue; } if (c == 'A') { x -= steps; } else if (c == 'D') { x += steps; } else if (c == 'W') { y += steps; } else { y -= steps; } } System.out.println(x + "," + y); } } }