def new_position(n, p, x, y, direction):
    directions = {
        'N': (-p, 0),
        'S': (p, 0),
        'W': (0, -p),
        'E': (0, p),
        'NE': (-p, p),
        'NW': (-p, -p),
        'SE': (p, p),
        'SW': (p, -p)
    }
    
    dx, dy = directions[direction]
    
    new_x = (x + dx) % n
    new_y = (y + dy) % n
    
    return new_x, new_y

n, p = map(int, input().split())
x, y = map(int, input().split())
direction = input().strip()

final_x, final_y = new_position(n, p, x, y, direction)

print(final_x, final_y)