欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1481A.Space Navigation
Space Navigation
You were dreaming that you are traveling to a planet named Planetforces on your personal spaceship. Unfortunately, its piloting system was corrupted and now you need to fix it in order to reach Planetforces.

Space can be represented as the plane. You are starting at point , and Planetforces is located in point .
The piloting system of your spaceship follows its list of orders which can be represented as a string . The system reads from left to right. Suppose you are at point and current order is :
- if , you move to ;
- if , you move to ;
- if , you move to ;
- if , you move to .
Since string could be corrupted, there is a possibility that you won't reach Planetforces in the end. Fortunately, you can delete some orders from but you can't change their positions.
Can you delete several orders (possibly, zero) from in such a way, that you'll reach Planetforces after the system processes all orders?
Input
The first line contains a single integer () — the number of test cases.
Each test case consists of two lines. The first line in each test case contains two integers and (; ) — the coordinates of Planetforces .
The second line contains the string (: is the length of string ) — the list of orders.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print "YES" if you can delete several orders (possibly, zero) from in such a way, that you'll reach Planetforces. Otherwise, print "NO". You can print each letter in any case (upper or lower).
Note
In the first case, you don't need to modify , since the given will bring you to Planetforces.
In the second case, you can delete orders , , , , and , so becomes equal to "UR".
In the third test case, you have to delete order , otherwise, you won't finish in the position of Planetforces.
Samples
6
10 5
RRRRRRRRRRUUUUU
1 1
UDDDRLLL
-3 -5
LDLDLDDDR
1 2
LLLLUU
3 -2
RDULRLLDR
-1 6
RUDURUUUUR
YES
YES
YES
NO
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |