ارسال شماره 988

← همه ارسال‌ها

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int p = sc.nextInt();

        int[] position = new int[]{
                sc.nextInt(),
                sc.nextInt()
        };
        sc.nextLine();

        String s = sc.nextLine();

        int[] direction = new int[]{
                p * ((s.contains("E") ? 1 : 0) - (s.contains("W") ? 1 : 0)),
                p * ((s.contains("S") ? 1 : 0) - (s.contains("N") ? 1 : 0))
        };


        for (int i = 0; i < 2; i++) {
            position[i] = (((position[i] + direction[i]) % n)+n)%n;
        }


        System.out.print(position[0]+" "+position[1]);

    }


}