What are you doing at the end of the world? Are you busy? Will you save us?

Nephren is playing a game with little leprechauns.

She gives them an infinite array of strings, f0... ∞.

f0 is "What are you doing at the end of the world? Are you busy? Will you save us?".

She wants to let more people know about it, so she defines fi =  "What are you doing while sending "fi - 1"? Are you busy? Will you send "fi - 1"?" for all i ≥ 1.

For example, f1 is

"What are you doing while sending "What are you doing at the end of the world? Are you busy? Will you save us?"? Are you busy? Will you send "What are you doing at the end of the world? Are you busy? Will you save us?"?". Note that the quotes in the very beginning and in the very end are for clarity and are not a part of f1.

It can be seen that the characters in fi are letters, question marks, (possibly) quotation marks and spaces.

Nephren will ask the little leprechauns q times. Each time she will let them find the k-th character of fn. The characters are indexed starting from 1. If fn consists of less than k characters, output '.' (without quotes).

Can you answer her queries?

Input

The first line contains one integer q (1 ≤ q ≤ 10) — the number of Nephren's questions.

Each of the next q lines describes Nephren's question and contains two integers n and k (0 ≤ n ≤ 105, 1 ≤ k ≤ 1018).

Output

One line containing q characters. The i-th character in it should be the answer for the i-th query.

Examples
input

Copy
3
1 1
1 2
1 111111111111
output

Copy
Wh.
input

Copy
5
0 69
1 194
1 139
0 47
1 66
output

Copy
abdef
input

Copy
10
4 1825
3 75
3 530
4 1829
4 1651
3 187
4 584
4 255
4 774
2 474
output

Copy
Areyoubusy
Note

For the first two examples, refer to f0 and f1 given in the legend.

长度预处理+递归

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 2147483647
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define ri register int
template <class T> inline T min(T a, T b, T c)
{
return min(min(a, b), c);
}
template <class T> inline T max(T a, T b, T c)
{
return max(max(a, b), c);
}
template <class T> inline T min(T a, T b, T c, T d)
{
return min(min(a, b), min(c, d));
}
template <class T> inline T max(T a, T b, T c, T d)
{
return max(max(a, b), max(c, d));
}
#define scanf1(x) scanf("%d", &x)
#define scanf2(x, y) scanf("%d%d", &x, &y)
#define scanf3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define scanf4(x, y, z, X) scanf("%d%d%d%d", &x, &y, &z, &X)
#define pi acos(-1)
#define me(x, y) memset(x, y, sizeof(x));
#define For(i, a, b) for (int i = a; i <= b; i++)
#define FFor(i, a, b) for (int i = a; i >= b; i--)
#define bug printf("***********\n");
#define mp make_pair
#define pb push_back
const int N = ;
// name*******************************
ll len1,len2,len3;
ll f[N];
string s0="What are you doing at the end of the world? Are you busy? Will you save us?";
string s1="What are you doing while sending \"";
string s2="\"? Are you busy? Will you send \"";
string s3="\"?";
int q,n;
// function******************************
void init()
{
f[]=s0.size();
len1=s1.size();
len2=s2.size();
len3=s3.size();
For(i,,N)
{
if(f[i-]>=INF)
{
f[i]=INF;
continue;
}
f[i]=len1+f[i-]+len2+f[i-]+len3;
}
} void solve(ll n,ll k)
{
if(n==)
{
printf("%c",s0[k-]);
return;
}
if(k<=len1)
{
printf("%c",s1[k-]);
}
else if(k<=len1+f[n-])
{
solve(n-,k-len1);
}
else if(k<=len1+f[n-]+len2)
{
printf("%c",s2[k-len1-f[n-]-]);
}
else if(k<=len1+f[n-]+len2+f[n-])
{
solve(n-,k-len1-f[n-]-len2);
}
else
{
printf("%c",s3[k-len1-f[n-]-len2-f[n-]-]);
}
} //***************************************
int main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
// freopen("test.txt", "r", stdin);
// freopen("outout.txt","w",stdout);
scanf("%d",&q);
init();
while(q--)
{
ll a,b;
scanf("%lld%lld",&a,&b);
if(f[a]<b)
{
printf(".");
continue;
}
solve(a,b);
} return ;
}

A. Nephren gives a riddle的更多相关文章

  1. CodeForces - 896A Nephren gives a riddle

    A. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. CF&&CC百套计划1 Codeforces Round #449 A. Nephren gives a riddle

    http://codeforces.com/contest/896/problem/A 第i个字符串嵌套第i-1个字符串 求第n个字符串的第k个字母 dfs #include<map> # ...

  3. Codeforces Round #449 [ C/A. Nephren gives a riddle ] [ D/B. Ithea Plays With Chtholly ]

    PROBLEM C/A. Nephren gives a riddle 题 http://codeforces.com/contest/896/problem/A codeforces 896a 89 ...

  4. 寒假特训——搜索——H - Nephren gives a riddle

    What are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a gam ...

  5. Codeforces Round #449 (Div. 2)-897A.Scarborough Fair(字符替换水题) 897B.Chtholly's request(处理前一半) 897C.Nephren gives a riddle(递归)

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces 897C Nephren gives a riddle:模拟【珂学】

    题目链接:http://codeforces.com/contest/897/problem/C 题意: 给你一些字符串: A: [What are you doing at the end of t ...

  7. CF897C Nephren gives a riddle

    思路: 递归. 比赛的时候脑抽了len[]没算够,wa了几次. 实现: #include <bits/stdc++.h> using namespace std; using ll = l ...

  8. Codeforces 897 C.Nephren gives a riddle-递归

    C. Nephren gives a riddle   time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. zsh: command not found cnpm,gulp等命令在zsh终端上报错的问题

    以cnpm包为例,使用 npm install -g cnpm 创建了cnpm包.而在zsh终端上运行cnpm,出现 zsh: command not found: cnpm 的报错.同样的,gulp ...

  2. django项目一 CRM表结构

    from django.db import models from django.contrib import auth from django.core.exceptions import Perm ...

  3. JavaScript高级编程——Array数组迭代(every()、filter()、foreach()、map()、some(),归并(reduce() 和reduceRight() ))

    JavaScript高级编程——Array数组迭代(every().filter().foreach().map().some(),归并(reduce() 和reduceRight() )) < ...

  4. js-react组件生命周期

    组件的生命周期可分成三个状态: Mounting:已插入真实 DOM Updating:正在被重新渲染 Unmounting:已移出真实 DOM 生命周期的方法有: componentWillMoun ...

  5. SAP Overview

    SAP的全称:       Anwendungen Produkte in der Datenverarbeitung (德文,这是原西德产品),翻译成英文就是:System,Applications ...

  6. iftop 命令

    在Linux中有一个可以实施监控网络流量的一个工具那就是我们这次要说的iftop命令,这个命令不是系统自带的内置命令,在使用之前是需要先进行安装的 安装方式:yum -y install iftop就 ...

  7. 【疑难杂症04】EOFException异常详解

    最近线上的系统被检测出有错误日志,领导让我检查下问题,我就顺便了解了下这个异常. 了解一个类,当然是先去看他的API,EOFException的API如下: 通过这个API,我们可以得出以下信息: 这 ...

  8. [Java] 用 Comparator 实现排序

    最近正好用到Comparator,发现能对不同类型的对象进行排序(当然排序依据还是基本类型),也不用自己实现排序算法,用起来很方便,所以简单记录一下. 本文地址:http://www.cnblogs. ...

  9. 学习vue.js的正确姿势(转载)

    最近饶有兴致的又把最新版 Vue.js 的源码学习了一下,觉得真心不错,个人觉得 Vue.js 的代码非常之优雅而且精辟,作者本身可能无 (bu) 意 (xie) 提及这些.那么,就让我来吧:) 程序 ...

  10. 使用 Azure PowerShell 监视和更新 Windows 虚拟机

    Azure 监视使用代理从 Azure VM 收集启动和性能数据,将此数据存储在 Azure 存储中,并使其可供通过门户.Azure PowerShell 模块和 Azure CLI 进行访问. 使用 ...