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 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.

 

先把题目的字符串形式想好。以下f(i)均带双引号。

f(0)带上双引号有77个字符

f(i)的形式是:      1个"  33个   f(i-1)   30个   len(i-1)  1个  1个"   整理为str1,f(i-1),str2,f(i-1),str3

设len(i):f(i)的长度。则len[i]=2*len[i-1]+66   ,在n为60时就爆long long 了,需要一个小技巧,因为k<1e18,len(55)≈5e18,故n>=55时字符一定在范围内,不会超出,而且因为len(i)>2*len(i-1),一定第k个要么位于str1,要么位于f(i-1),在55以内longlong可以表示下,故n>55的话一直递归到55一下再说。

开始时的f(n)不带双引号,小于n的均带,初始时特判一下。

很恶心的dfs+字符串。

#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll q,n,k,len[60];

char f0[]= "\"What are you doing at the end of the world? Are you busy? Will you save us?\"";
char f11[]="\"What are you doing while sending ";
char f12[]="? Are you busy? Will you send ";
char f13[]="?\"";

void init()
{
	len[0]=77;
	for(int i=1;i<=55;i++)len[i]=2*len[i-1]+66;
}

void dfs(ll n,ll k)
{ 
	if(n>55&&k<=34){putchar(f11[k-1]);return;}
	if(n>55&&k>34)return dfs(n-1,k-34);
	if(n<=55&&k>len[n]){putchar('.');return;}   //这里和初始的特判区别在于有无"" 
	if(n==0){putchar(f0[k-1]);return ;}
	if(k<=34){putchar(f11[k-1]);return ;}
	if(k>=34+len[n-1]+1&&k<=34+len[n-1]+30){putchar(f12[k-1-34-len[n-1]]);return ;}
	if(k>=64+2*len[n-1]+1){putchar(f13[k-1-64-2*len[n-1]]);return ;}
	if(k<=34+len[n-1])return dfs(n-1,k-34);
	return dfs(n-1,k-64-len[n-1]);
}

int main()
{
//	freopen("input.in","r",stdin);
	init();
	cin>>q;
	while(q--)
	{
		cin>>n>>k;
		if(n<=55&&k>len[n]-2){putchar('.');continue;}
		dfs(n,k+1); // have "" 
	}
	putchar('\n');
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值