CPU: 1s
Memory: 1024MB
আবদুল্লাহ বাংলাদেশের একজন ছোট্ট অভিযাত্রী। সে একাই ধূধূ মরুভূমিতে তার জিপিএস এবং রেডিও নিয়ে যাত্রা করছে। সে বেসক্যাম্পের সাথে নিয়মিত যোগাযোগ রাখে, যাতে বড়রা তার অবস্থান এবং নিরাপত্তা নিয়ে চিন্তিত না হয়।
হঠাৎ আবদুল্লাহ আবিষ্কার করল যে তার জিপিএস আর রেডিও কোনটাই কাজ করছে না। শেষ যেখানে জিপিএস ঠিকমত কাজ করেছিল আবদুল্লাহ সেই অবস্থানটি জানে, কিন্তু সে তার বর্তমান অবস্থান জানে না। তার অবস্থান XY তলের একটি বিন্দু হিসেবে প্রকাশ করা যায়, যেখানে X অক্ষ পশ্চিম হতে পূর্ব দিকে এবং Y অক্ষ দক্ষিণ হতে উত্তর দিকে। আবদুল্লাহ এটাও জানে যে সে কোন দিকে কত মাইল যাত্রা করেছিল। সে শুধুমাত্র উত্তর, দক্ষিণ, পূর্ব এবং পশ্চিম দিকে যাত্রা করেছিল।
হঠাৎ তার রেডিও কাজ করা শুরু করল এবং সে তৎক্ষণাৎ তার সর্বশেষ জানা অবস্থান এবং তার পর থেকে সে কোন দিকে কতটুকু গিয়েছিল তা রেডিওর সাহায্যে বেসক্যাম্পে প্রেরণ করল। বেসক্যাম্পের লোকেরা কি পারবে আবদুল্লাহর বর্তমান অবস্থান চিহ্নিত করতে?
Abdullah is a young explorer from Bangladesh. He has traveled to the Never Never Land to explore the vast deserts there. Equipped with his GPS and radio transmitter, he is travelling through the deserts all by himself. He keeps regular contact with the Base Camp, so that the Elders are aware of his location and his safety.
Suddenly, Abdullah finds his GPS is not working! And as luck would have it, his radio transmissions are also failing. Wandering in the desert, he no longer knows his current position. However, he remembered his last known position. The position can be represented as a point in a 2 dimensional XY plane, where the x axis runs from West to East and y axis from South to North. He also kept track of the directions he traveled and for how many miles. He only traveled along North, South, East and West.
All on a sudden, his radio starts working and he immediately transmits his last known position and the sequence of moves he made thereafter. Can the people in the Base Camp identify his current location?
ইনপুটের বর্ণনা
ইনপুটের প্রথম লাইনে টেস্টকেসের সংখ্যা T দেওয়া থাকবে। প্রতিটি টেস্টকেসের প্রথম লাইনে স্পেস দিয়ে আলাদা করাদুইটি পূর্ণসংখ্যা X এবং Y দেওয়া থাকবে, যা আবদুল্লাহর সর্বশেষ জানা অবস্থান নির্দেশ করে। পরবর্তী লাইনে একটি স্ট্রিং দ্বারা সে কোন দিকে কতটুকু গিয়েছিল তা দেওয়া থাকবে। সরণের সংখ্যা হবে 1 হতে 10000 এর মধ্যে। তার প্রতিটি সরণ দুইটি বর্ণ দিয়ে প্রকাশ করা হবে। প্রথম বর্ণটি হবে N, S, E অথবা W, যা নির্দেশ করে সরণের দিক। পরের বর্ণটি হবে 0 হতে 9 এর মধ্যে, যা সে কত মাইল গিয়েছিল তা প্রকাশ করে।
Input
The first line of the input contains T, the number of test cases . The first line of each test case contains 2 space separated integers x, y, representing Abdullah’s last known position. Next line contains a string representing his subsequent moves. There can be at least 1 move and at most 10000 moves. Each move is represented by 2 letters. The first letter is either of N, S, E, W representing the direction he traveled. The next letter is between 0 and 9. It represents the number of miles he traveled in that direction. The subsequent test case starts in the next line.
অাউটপুটের বর্ণনা
প্রতিটি টেস্টকেসের জন্য একটি লাইনে স্পেস দিয়ে আলাদা করা দুইটি পূর্ণসংখ্যা X এবং Y আউটপুট দিতে হবে, যা আবদুল্লাহর বর্তমান অবস্থানের স্থানাংকদ্বয় নির্দেশ করে।
Output
For each test case output 2 space separated integers representing the x and y coordinates of Abdullah’s current position.
Limit
1 <= T <= 10
0 <= x, y <= 1000
Sample
Input | Output |
---|---|
2 2 2 N9W2N3W5S9E2S6 3 5 E9S9E5S2W4N9W3S7 | -3 -1 10 -4 |