#include <iostream>
using namespace std;
int main()
{
    int n , p;     cin >> n >> p;
    int x , y;     cin >> x >> y;
    string lulu;   cin >> lulu;

    if ( lulu == "N" )
    {
        x += p;

        if ( x >= n )
        {
            x = x - n;
        }
    }

    else if ( lulu == "S" )
    {
        x = x - p;

        if ( x < 0 )
        {
            x = abs(x);
        }
    }

    else if ( lulu == "W" )
    {
        y += p;

        if ( y >= n )
        {
            y = y - n;
        }
    }

    else if ( lulu == "E" )
    {
        y = y - p;

        if ( y < 0 )
        {
            y = abs(y);
        }
    }

    else if ( lulu == "NE" )
    {
        if ( p % 2 == 0 )
        {
            x = x + p/2;
            y = y - p/2;

            if ( x >= n )
            {
                x = x - n;
            }

            if ( y < 0 )
            {
                y = abs(y);
            }
        }
        
        else 
        {
            x = x + p/2 + 1;
            y = y - p/2;

            if ( x >= n )
            {
                x = x - n;
            }

            if ( y < 0 )
            {
                y = abs(y);
            }
        }
    }

    else if ( lulu == "NW" )
    {
         if ( p % 2 == 0 )
        {
            x = x + p/2;
            y = y + p/2;

            if ( x >= n )
            {
                x = x - n;
            }

            if ( y >= n )
            {
                y = y - n;
            }
        }
        
        else 
        {
            x = x + p/2 + 1;
            y = y + p/2;

            if ( x >= n )
            {
                x = x - n;
            }

            if ( y >=  n )
            {
                y = y = n;
            }
        }
    }

    else if ( lulu == "SE" )
    {
         if ( p % 2 == 0 )
        {
            x = x - p/2;
            y = y - p/2;

            if ( x < 0 )
            {
                x = abs(x);
            }

            if ( y < 0 )
            {
                y = abs(y);
            }
        }
        
        else 
        {
            x = x - p/2 - 1;
            y = y - p/2;

            if ( x < 0 )
            {
                x = abs(x);
            }

            if ( y < 0 )
            {
                y = abs(y);
            }
        }
    }

    else if ( lulu == "SW" )
    {
         if ( p % 2 == 0 )
        {
            x = x - p/2;
            y = y + p/2;

            if ( x < 0 )
            {
                x = abs(x);
            }

            if ( y >= n )
            {
                y = y - n;
            }
        }
        
        else 
        {
            x = x - p/2 - 1;
            y = y + p/2;

            if ( x < 0 )
            {
                x = abs(x);
            }

            if ( y >= n )
            {
                y = y - n;
            }
        }
    }

    cout << x << " " << y;

    return 0;
}