#include <cstdio>
#include <cstring>
#include <cstdlib> #define MAXN 100005
#define MOD 1000000007
int que[MAXN], front = , rear = ;
int n; void query(int index) {
int r = rear;
int square = ;
int half = (n+)>>; while (r-- > front) {
if (que[r] == ) {
++square;
} else if (que[r] == ) {
index = n+-index;
} else {
if (index > half) {
index = (index - half)*;
} else {
index = *index - ;
}
}
}
__int64 ret = index%MOD;
for (int i=; i<square; ++i) {
ret = ret*ret%MOD;
}
printf("%I64d\n", ret);
} int main() {
int t, m;
int x;
char cmd[]; scanf("%d", &t);
while (t--) {
rear = ;
scanf("%d%d", &n, &m);
while (m--) {
scanf("%s %d", cmd, &x);
if (cmd[] == 'Q') {
query(x);
} else {
que[rear++] = x;
}
}
}
return ;
}

最新文章

  1. Notepade ++ 替换每行最后的换行符
  2. jQuery监听键盘事件及相关操作使用教程
  3. gitingore
  4. [转] - SendMessage、PostMessage原理
  5. 引擎设计跟踪(九.14.2i) Android GLES 3.0 完善
  6. Spring+MyBatis实践—登录和权限控制
  7. Eclipse中Cannot find any provider supporting DES解决之道
  8. redis 系列13 集合对象
  9. python语言的基本要素
  10. HIT2019春软件构造-&gt;重写hashCode()方法
  11. spring cloud+.net core搭建微服务架构:配置中心续(五)
  12. flask 使用宏渲染表单(包含错误信息)
  13. python零散补充与总结
  14. bzoj4271: chemistry 化学
  15. ecloipse背景修改豆沙
  16. [NOIp2016]蚯蚓 (队列)
  17. python基础之collections模块
  18. 剑指offer——面试题29:顺时针打印矩阵
  19. linux 命令行基础
  20. 使用spring-loaded实现应用热部署

热门文章

  1. 搭建自己的SIPserver:开源sipserveropensips的搭建及终端TwInkle的使用
  2. CreateFont具体解释
  3. linux中 vi / vim显示行号或取消行号命令
  4. [转] HBase的特征和优点
  5. Java基础知识强化之IO流笔记11:递归之递归概述和注意事项
  6. TCP/IP协议原理与应用笔记10:TCP/IP协议族
  7. discuz! X3 门户文章添加字段
  8. C#解leetcode 219. Contains Duplicate II
  9. phonegap 2.8.1 toast
  10. Linux安装配置mongodb