QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#817209#3291. String PuzzleSGColinAC ✓11ms3772kbC++201.4kb2024-12-16 20:55:232024-12-16 20:55:24

Judging History

你现在查看的是最新测评结果

  • [2024-12-16 20:55:24]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:3772kb
  • [2024-12-16 20:55:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

inline int rd() {
	int x = 0;
	bool f = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) f |= (c == '-');
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	return f ? -x : x;
}

template<typename T>
inline bool getmin(T &a, T b) {return a > b ? (a = b, true) : false;}

#define N 1007

pair<int, char> hint[N];

int y[N], h[N], tot;

struct segpair{
	int l, r, h;
	inline bool operator < (const segpair &obj) const {return r < obj.r;}
} s[N];

map<int, char> f;

int main() {
	int n = rd(), a = rd(), b = rd(), q = rd();
	for (int i = 1; i <= a; ++i) {
		int p = rd();
		char c = getchar();
		while (!isalpha(c)) c = getchar();
		hint[i] = {p, c};
	}
	for (int i = 1; i <= b; ++i) {y[i] = rd(); h[i] = rd();}
	y[b + 1] = n + 1;
	for (int i = 1; i <= b; ++i) if (h[i]) s[++tot] = {y[i], y[i + 1] - 1, h[i]};
	
	auto find = [&](int p) {
		if (!tot) return p;
		for (int i = tot; i; --i) {
			if (p > s[i].r) return p;
			if (p < s[i].l) continue;
			p = s[i].h + (p - s[i].h) % (s[i].l - s[i].h);
		}
		return p;
	};

	for (int i = 1; i <= a; ++i) f[find(hint[i].first)] = hint[i].second;
	for (int i = 1; i <= q; ++i) {
		int pos = find(rd());
		putchar(f.find(pos) == f.end() ? '?' : f[pos]);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3644kb

input:

734528558 1000 31 1000
41618 A
942442 A
1120489 A
1255378 A
2313364 A
2913705 A
5366241 A
6186259 A
6480774 A
7640800 A
7960158 A
8351730 A
8974661 A
12399184 A
13235324 A
13647596 A
13914995 A
13997995 A
15111451 A
15150167 A
17779423 A
18163296 A
18561829 A
18890893 A
19359049 A
19447455 A
1953049...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok single line: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

928213110 1000 27 1000
25267 A
1606087 A
2845913 A
3031995 A
3068766 A
3409353 A
3840809 A
4798561 A
5162927 A
6118738 A
6568006 A
7356337 A
7435745 A
7735463 A
7775151 A
9238647 A
9268386 A
9326454 A
11149525 A
14521977 A
14601090 A
15263443 A
15529929 A
17797644 A
20115373 A
20778946 A
22467218 A
...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok single line: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3732kb

input:

960238253 1000 30 1000
374104 A
2904631 A
4084090 A
5290151 A
5645295 A
6254408 A
7760025 A
7891948 A
7940445 A
8276876 A
10749857 A
11012407 A
11684096 A
12646958 A
12967505 A
13803825 A
14773260 A
15127221 A
15402240 A
15751484 A
16260058 A
16592744 A
18006861 A
20429408 A
21139315 A
21893318 A
25...

output:

AAAA??A????AA?A?AAA?A?AAAA?AA??????A?AAAA???AA??A?AAAAAA????A?AAAAAAAA?AAAAAAAAAAAAA?A?A?AA?AA?AAA?A??AAAAA??A?AA?AAAAAA?A?AA?AA??A???AA???A?A???AA????AAAAAA?AA?AAA?A?A??AAAA?A?AA?A??A??A??????AAAAA??A??AA??A?A?AAAA?A?AAA??A?AAAA?AAAA??AA?A?????AA????A???A??AAAAAA??AAA???A??AAA???AA?AA??AA??A???AAA?...

result:

ok single line: 'AAAA??A????AA?A?AAA?A?AAAA?AA?...???A??AA??AAA?AAAAAA?????AAAA??'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

710214429 1000 33 1000
828415 A
3360039 A
4342719 A
4482309 A
5260592 A
5939337 A
6999075 A
8445818 A
9157174 A
9189326 A
9894784 A
10800681 A
11487752 A
12655835 A
13482242 A
14152188 A
14170672 A
14682392 A
14995641 A
16307897 A
16855975 A
16986864 A
17251296 A
17370730 A
18544439 A
18601880 A
186...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok single line: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

853653980 1000 33 1000
2714506 D
2740215 E
2893952 R
4386535 R
4755928 R
4897135 O
5421601 O
6201092 E
9750201 L
11350246 L
12129192 B
12746697 O
12775208 D
12884068 W
13033569 L
13272590 D
16109417 O
16831127 O
16852126 L
20864720 R
22285958 O
22516971 O
23241118 D
24579947 L
26677636 O
26985726 G
...

output:

EDOLODRGOHLLGOODOEDEBGOGEREHERLREGEGLYDLEEGOOODYRLEEYEEDOERBROYLWDWEWHOLLGHLWEDEOEDYEBLDEDEEOBHDDLLLELOOEROEYODOOLGOWYOBYLBODOWDBWLYDOBEOOEOEOOEOROEEEODEYEOLYBDHOLWBLDWDODLWOOHRDOLHOYYLWYLWLWLEOGBOBELEOOGLDLOOHHOOYOOELLLLBOROEGLOOGELEDOBLOBODDOELOWGEGRYOBGRWOWOOOEHLERLGEOLDLEWGGGWEOGROWDEWDBODOOELEO...

result:

ok single line: 'EDOLODRGOHLLGOODOEDEBGOGEREHER...DWRLOEDWGGRYGHOEWOBGWWOEEERBLOO'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

834354101 1000 24 1000
3034 R
887411 G
2675128 R
3215870 D
5939304 D
8685015 L
8838113 E
10456568 L
10538241 L
11314717 D
13287855 L
14021851 O
16601087 L
17572083 Y
17879540 G
21876315 H
23363904 O
23499893 G
23866775 Y
25587043 L
26915644 L
29715983 E
29737737 G
30493565 E
30714809 R
31478303 B
31...

output:

HEGRGBWLOEOHEBDLHREOLHYLRODELODLWRYREBBRLRBLOWLEWDELLDWYDBDBOBGYEEYREDODOLLBLBDHLDDWOOLGYEDOBOOBERBBLOODEOOYWDOWOHOODOBDLWWEDDGOHWLODLHRLEELODOOEOHELOWOWYOWDDGGDEHBLLHELDBYYWDRLOOWDDYWOLLBEORLDYOEROWOGEROEGDDOEOOEOLHELYDWGYODLEYEWLDORDHGYLLLLLDRDEWOHBEBELEOOWBOLRGGOEOOGRDLLEODDOOGEHBOWGEWLHEWRLBOOEW...

result:

ok single line: 'HEGRGBWLOEOHEBDLHREOLHYLRODELO...ERLWDRRHOLEHYOOWYGBYEDROOYOLEHO'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

677314489 1000 27 1000
1096803 Z
1804326 D
2093632 H
2749697 C
4273270 W
4804699 L
6340139 A
8463125 A
10040220 A
10905327 D
10913638 D
12749593 F
12850212 A
12954161 N
13305200 P
15121973 O
16064606 S
16194441 F
16967482 F
17500330 Y
17717521 U
18245054 D
18590972 K
18722982 S
18863074 E
20511179 D...

output:

??????????????????L????????????????????????????????????B?????????????????????????????????????????????????????????????????????B??????????????????I???????????????????????????????????A????????P????????Z????????????????????????B?????????????????????????????????????????????B?????????????GA???????????????...

result:

ok single line: '??????????????????L???????????...???????????????????????????????'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

928884593 1000 27 1000
1553798 S
2701061 H
6963107 R
7362920 R
7839992 J
8787222 M
8998457 S
9647391 A
11386838 C
11394595 A
12135892 R
14881575 L
16990616 R
17769099 U
19281067 U
19534403 R
20335989 Z
21449873 A
22596073 J
22642137 H
23129851 A
23488832 A
23763476 A
24721178 I
25347068 Y
25651844 R...

output:

HAAXECBRBNAPAWQPRJKNZRHBJABEPAASLJRMAARXRADQSBJRHGLCRTANPURAXQAGVFDLUAPTAPPUGACVMWKMBBBDBAKSRUAYEFXMPAOCAEBUBAAALQRBZKAARMPWCTNPADMRXPVREARYAURATBWWRDCHAWYKPJGMRABANFNDDQAAVWEMKANSYARWIAYTPZVBDCDGAPBXRAEMJVEATHCWPHZNPPJPLBARDLCIZRQBCAZRZCHBAABMBADAWDUMHHPHXAACMMZAKACOGIAABUZAXCABAALDFEUAARBYTLHTAVCA...

result:

ok single line: 'HAAXECBRBNAPAWQPRJKNZRHBJABEPA...MBELABURGVCBCTARUHBDMINNPEKAZYB'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

1000000000 1 1 2
1 Z
2 1
1
1000000000

output:

ZZ

result:

ok single line: 'ZZ'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

1000000000 1 1 2
1000000000 A
2 1
1
1000000000

output:

AA

result:

ok single line: 'AA'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

1000000000 1000 30 1000
565771 B
1397000 B
1748366 B
2731059 B
3769029 B
4228862 B
4284876 B
6764164 B
6926125 B
8593908 B
9158086 B
10267117 B
14763800 B
14976250 B
14977747 B
16752084 B
18580127 B
19756786 B
19971020 B
22004258 B
22461727 B
23173348 B
23277381 B
23992694 B
25870784 B
26149754 B
26...

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok single line: 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

1 0 0 1
1

output:

?

result:

ok single line: '?'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

1 1 0 1
1 Q
1

output:

Q

result:

ok single line: 'Q'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

2 2 0 2
1 Z
2 A
1
2

output:

ZA

result:

ok single line: 'ZA'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

2 2 1 2
1 Z
2 A
2 0
1
2

output:

ZA

result:

ok single line: 'ZA'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

2 1 0 2
1 Z
1
2

output:

Z?

result:

ok single line: 'Z?'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

2 1 1 2
2 A
2 0
1
2

output:

?A

result:

ok single line: '?A'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

2 0 1 2
2 0
1
2

output:

??

result:

ok single line: '??'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

2 2 0 2
1 Y
2 Y
1
2

output:

YY

result:

ok single line: 'YY'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

2 2 1 2
1 Y
2 Y
2 1
1
2

output:

YY

result:

ok single line: 'YY'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

2 2 1 2
1 Y
2 Y
2 0
1
2

output:

YY

result:

ok single line: 'YY'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

2 1 0 2
1 Y
1
2

output:

Y?

result:

ok single line: 'Y?'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

2 1 1 2
1 Y
2 1
1
2

output:

YY

result:

ok single line: 'YY'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

2 1 1 2
1 Y
2 0
1
2

output:

Y?

result:

ok single line: 'Y?'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

2 1 0 2
2 Y
1
2

output:

?Y

result:

ok single line: '?Y'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

2 1 1 2
2 Y
2 1
1
2

output:

YY

result:

ok single line: 'YY'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

2 1 1 2
2 Y
2 0
1
2

output:

?Y

result:

ok single line: '?Y'

Test #28:

score: 0
Accepted
time: 11ms
memory: 3688kb

input:

999991106 963 1000 1000
998991690 D
998994643 U
998994806 G
998995830 Q
998997211 W
998997234 Q
998997797 Z
998998645 H
998999394 F
998999584 I
999001851 G
999005263 G
999009347 V
999010643 O
999014645 V
999016183 J
999016844 D
999017406 A
999017828 E
999017833 P
999018022 T
999019266 U
999023593 P
...

output:

YWZMTJ?YEQLVYNTSOOPMFZAXUXWAWPUIJHCTWABXOCATFJABOTGPYBXFCLCB?EZTDAHN?EOBCJWVHJXBVZG?Z??UTBTMYLKPWUE?BFKWAWCVKTUJEXDGIAACGKPUTCGWYUNWKOKOQSDIHTEOYUSDTUYLU?GGCDJQRBIUCUITLECUBZCLIKZFAQCQPIGHWOSHENRAPYIFQ?IENSNGYREHLSY?AN?OSYJRVJEDXDNVIWQIUEWQCHNBQMMYEFFTYGV?DRBPHXNBRXKFSOZNZRTWKCMYRRLZWLTVZYVDAEKUXOJ?...

result:

ok single line: 'YWZMTJ?YEQLVYNTSOOPMFZAXUXWAWP...PIVGLRQ?VBGVEAXSDJCSRBDILBAOXWY'

Test #29:

score: 0
Accepted
time: 7ms
memory: 3772kb

input:

999992594 959 996 999
998988185 T
998991071 K
998992396 Q
998992899 U
998995860 T
998996186 P
998996325 E
998996596 O
998997608 L
998997717 X
999000951 G
999003585 Z
999004012 X
999005781 X
999005909 I
999006901 H
999008491 B
999008862 H
999009381 T
999009668 F
999010037 O
999010096 R
999012401 W
99...

output:

QFNXHYYSGGWK??DRO?IRVLOHP?IHYBGNBBOELJSALDZNGTOXUPIENALESMMINRTEOJYD?NWPURRUIPONJJFFF?JHAWSKCQCFIBQQBKHJRWWQKYAI?LZNCPZ?NYKKCNCNI?JJLUFDWOPYNAJIZUPVXSQJJJTXSSLODNAEDSSPZPDENZLTUOSUJHHUKWPSEZNRYYNCX?JILRYBNKQ?ITJJXWJBAIGDTIQRFYMEUPHLAFROUPW??LLUUWJS?JFAKPRL?WRZJAOQSWAHHLYCDHMKCKHUBNUHEXLVWHQZQWFFOESM...

result:

ok single line: 'QFNXHYYSGGWK??DRO?IRVLOHP?IHYB...BXGNMBLFSVAL?GQOWCYDMRLKRYEZSCT'

Test #30:

score: 0
Accepted
time: 11ms
memory: 3764kb

input:

999987751 968 997 998
998984115 Y
998984478 L
998985987 V
998987775 S
998988542 U
998989017 T
998989267 R
998991785 O
998992536 T
998993039 U
998993840 D
998994133 B
998995962 Y
998997397 I
998998851 W
998998940 C
999001200 E
999001975 H
999003207 Q
999004376 Q
999004384 I
999004928 C
999006635 Y
99...

output:

SHLODIYRKCHHMJAUOKTASUH?RIYPRAIOFGHQKNWH?EGTCOJYQIBZTIEQIEFVPXRGEXEQARSWMDTVAISCIDWNEUSRET?RRYSFWOZCWQUSKXIPAGKTARJBR?UCHYXYKYKNPIZPDQQKUVGLRGGCJOOJPWWDZPEGIYKKMLKZQMWNNNWATQKQGRDTIQHUCYQVSXCEMHNGHSMLKWZK?CPFZFSZR?SWWKGXQDFPSVDSYCSHCNJJMCVETZGTKNUKUZWBCENVUBEKHKOBF?XPOLDTOAVPZYLMJVSQSQSETYBFJNNWDNX?...

result:

ok single line: 'SHLODIYRKCHHMJAUOKTASUH?RIYPRA...VLHMFXELHTXXBKSWBMKMHQIITMGEAXN'

Test #31:

score: 0
Accepted
time: 7ms
memory: 3692kb

input:

999987714 952 992 998
998979744 I
998980273 K
998980287 X
998981957 W
998982450 H
998982727 C
998983221 Z
998984573 T
998985429 O
998987089 C
998988084 Z
998990150 R
998990652 J
998991663 I
998993195 E
998993914 E
998994084 V
998995322 H
998995737 B
998996851 P
998998812 G
998999921 Q
999001287 F
99...

output:

B?FPIYDMKISMHINEEOGEAPTRXR??CPMWWGBBHODLXYBTJYYFTTWBXU?EEMQQLFSNAQRLQ?RBDNASBEPAF?PEOVPTHVFXQIPZFGVEJLDS?ZZHUNI?XXFFTAZYY?JGUFTVVDDAUIMSDFTEZFWHLKIHSKYWUCFJXGPRQNURJQJJDBKYKQVH?YMBTXQZMILEFHDQOAEAB?XLRYROONKM?NOHFFZTP?VCLXXODLDVRPTONQMZWEUVQANGTKSTEWHYAXHNAFV?VPSOCFZPMQBXWCIDTBXE?TMXELVWGPHVRAPTUYDC...

result:

ok single line: 'B?FPIYDMKISMHINEEOGEAPTRXR??CP...SIQP?VNDIJAVHS?MNTAOBPPDKRRLRWQ'

Test #32:

score: 0
Accepted
time: 11ms
memory: 3624kb

input:

999991653 961 999 999
998990809 H
998991238 Y
998991914 M
998992616 A
999000729 G
999000923 R
999002660 P
999004690 V
999006155 K
999006350 J
999006507 D
999006868 S
999007066 Y
999007868 Y
999008381 W
999009290 U
999009319 H
999009612 H
999009751 H
999010946 V
999011434 Z
999012059 M
999015298 G
99...

output:

NAFGOTSHGAAYQXVUVKZ?HXZKKHSJGURHNKXOYCSKOEFTBKDTAOJXGDMJMTQHAUGPSFUXJJEQSGNMAPBDMJRSIMFMLAYMSLBLEAGRJQBRYM?POBOZXMRUFJCQQESLXXFRJNKAQLUGJKRJHZVMNLGOTAEODUAPRSRMTOLAEFQHRDLMZLRFTIQD?ESJNWWPCBXTZZHCHLGWHTTACXGWKOGFPNOXOIHHLJIWHMLTJHSNTCFDGD?LIMPNZXAEVUFZZGUNPLKEHINHTLRWGVTTURIV?YUKVKUKXHOGBEAWXEAVEALS...

result:

ok single line: 'NAFGOTSHGAAYQXVUVKZ?HXZKKHSJGU...TYXXPXVHLKNWKUJTFTYZKKKZKOESIAO'

Test #33:

score: 0
Accepted
time: 11ms
memory: 3628kb

input:

999988112 957 995 999
998984946 K
998985223 E
998985829 Y
998985896 Y
998985985 X
998988249 Q
998988685 V
998988889 H
998991320 W
998994223 J
998994516 L
998995234 C
998995258 Y
998995842 C
998996216 A
998996492 V
998997937 Q
998999150 R
998999642 M
999000662 M
999002548 U
999002762 K
999003357 W
99...

output:

XOZJEMGQDDKSDYKZIYBUIAD?JHJRPXGRQHAJUHYANGWFUYOMURYIVPNSFADAAKXZHFEFA?GMLAYVEZQPNNSPPWTYDRTGVJOHKRLTVMTWHTKAHEVAKMCCOIWCPAVLLGIMCPFTFDOHSVYG?ZBQMARBF?DIYMEEY?EITXCWUDYNQR?Q?MOESZHRTSUTGAWHNQOYI?SUYWLXKFEKGPCDSR?KAZIP?CBFNRL?FVKIG?XEQDQOWFXDVBYLBKROHXAQOH?EGNIOJBXECFOZYEVYADTAGHTMZFLSYYTNLMCIKUPTA?QB...

result:

ok single line: 'XOZJEMGQDDKSDYKZIYBUIAD?JHJRPX...NWGZVOQHJRHZSEGNREZKAUYLHJJMQ?N'

Test #34:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

1000000000 1000 352 1000
2266072 A
2273579 A
5484256 A
7327309 A
7711236 A
8702147 A
12074021 A
12268518 A
13289194 A
13551908 A
13924261 A
14158986 A
14673395 A
15788910 A
17374403 A
18199471 A
18240748 A
18640252 A
19279221 A
19283904 A
19935527 A
20447277 A
20744446 A
22140120 A
22170076 A
235001...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok single line: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'

Test #35:

score: 0
Accepted
time: 2ms
memory: 3580kb

input:

999999991 1000 335 1000
943061 A
1028795 A
1506462 A
2289964 A
2641456 A
5561106 A
8362634 A
9732830 A
10151102 A
10640340 A
10734457 A
11540043 A
12273749 A
13025110 A
13783156 A
14182445 A
14908260 A
15488013 A
16005335 A
17247306 A
17660129 A
18298889 A
18327137 A
20038056 A
20414539 A
21384824 A...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok single line: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'

Test #36:

score: 0
Accepted
time: 3ms
memory: 3572kb

input:

999999984 1000 334 1000
1306077 Z
1579585 X
2293945 X
2971398 Z
3688265 Y
8385193 Y
8708205 Z
9158336 Y
13171122 Y
15192948 Z
16585188 Z
17973064 X
18469690 X
18763005 Y
19944090 X
20735044 X
21094118 Z
21855272 X
23191899 X
24504982 X
25182277 Y
25941749 Z
26573091 Z
27480881 Y
27872229 Y
28142398 ...

output:

ZZXZZYXYZZXYZXYZZZZZYZZZZZZZZZZZZYYZYZZZZZZXZZZZZZZZZZZZZZZXZZZZXZZZXZYZYZZZXZZXYXZZZZXXZZYZZZZZXZYYZZZZZZZZXZZZZZZZZZZZYXZZYYZZXXZZYZZZZYZZXZZZZYZYZZZYZZZXYYXZZZZZXYZZXZXZXZZZZYXZZXZZZXXZZZYZZZZYZZZXZZZYYZZZZYZZZXZZZYZYYZZZZYZXZZYYZYZZZZXZZZZZZZXZXYYZZZZZZZZZZZZZYYZZZYZYZYZXZXZYZZZZZXZYZZXZYZZZZZZZ...

result:

ok single line: 'ZZXZZYXYZZXYZXYZZZZZYZZZZZZZZZ...YZXZXZZXXZZZZYXZZYZXZZZYZZZZZZZ'

Test #37:

score: 0
Accepted
time: 3ms
memory: 3528kb

input:

999999876 1000 360 1000
219926 Y
5778120 Y
6147863 X
6319425 Z
6694533 Y
6886250 X
7250920 Y
7360813 Z
8445146 Y
9549155 X
9847355 X
10117734 Z
11175382 Z
11603041 Z
11938258 X
13720291 X
14554887 Z
15082406 X
15763091 Y
16637965 Z
18318087 Y
18359610 X
20614622 X
20630762 Z
21501347 Y
21655973 X
21...

output:

ZZZYZYZZYZZZZZZZZZXYZYZZXZZZZZYZXXYXZZXZZZZZZXXZZXZXXZZZXYZYZXZZZXZZZZZYZZZZZXXXZXZZZZZZZXYZZZYZZZYZZXZZYZYZZXZZXZYZYZZZXZZZZZYZXZZZZZZXZZZZZZZYZXZZYZZYZYZZZZZZZYZZXZXZZZZZYXZZZZZZZZZZXZZZZZZYZZZZXZZXZXZZZZZZZZZZZZZZZYZYXZYZZZZYZZZZZXZZZZZZZZYZZYZZZZZYZZZXZZYZYZZZZXZZZXZXXZZZZYYZZZXZZZZZZZZZZZYZZZZZ...

result:

ok single line: 'ZZZYZYZZYZZZZZZZZZXYZYZZXZZZZZ...ZZYZZZZYZZXXZZZZZZZZZYZYZZZZXZZ'

Test #38:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

999999660 1000 345 1000
67325 B
3134297 B
3500953 A
3501602 P
3855246 C
5560252 T
6061775 S
8497584 U
8665112 T
9272631 C
10015144 T
10139520 A
10650787 A
11066423 C
11117947 K
11841415 A
15138884 A
15555777 K
15735365 C
16963303 M
17217606 A
18343989 C
20341066 B
20967183 C
21048762 C
21094128 A
21...

output:

KAAIACAUUAAABAAUCCAAPTUBPUBPBTPTUUTPBAUBAAATATBUABMBBBBKBBABBCACABMSBATABABABACUAAATCUUAABAAUSAABUAUIAAAPBMTMABACBAAIIABACUAAIMAAUUACICAAMIBATBCSPATABKUBATAAAUCABAUKBCAABAPCBCAABBBAAAABBMAUBBUSCCBABBAAUBCACCBBKBAAPAAABBABCCSCABAMBBBBACAKSIBCCABUAUCAIKUASUAPBUBBBBIAUMSUBAASBTACAUBCCAUABAAAABBBUBPAIAA...

result:

ok single line: 'KAAIACAUUAAABAAUCCAAPTUBPUBPBT...UCABUUBASBBBAKABSAAKTAMUBBACAUA'

Test #39:

score: 0
Accepted
time: 2ms
memory: 3656kb

input:

999999876 1000 344 1000
16779 C
245283 M
817450 I
2161057 M
2552347 C
3377568 U
4062619 C
5685190 B
5701192 B
9059019 U
9769471 U
10938190 B
10964971 B
11674529 A
11990196 B
15469249 B
17090036 B
17294464 B
18658563 B
19181249 B
21374487 A
22568210 U
24285186 A
24444980 A
30883824 B
32567838 B
32891...

output:

BABBBAABABBBUABABBBBABAAABBAABBBBAABBUABBAAABAAAABABBBAABAABAAABBBABAAAABBBBABABBBBABAAUBBBBABAABAAAAABABAAAABBBAAUAAABABBBABBAABBBBBBBAAUAAAAAUBAABABBBBBABAABBBBBABUBBABBABAABBABABBBAAAAABBBABABBAABBBAAAABABBAAABABAABBAAAABBBABBBBAAABABBABBAAAA?ABAABABBUBAAAABBBBBAABBAAABBAAAAABABBBABABBABBA?BBBBAA...

result:

ok single line: 'BABBBAABABBBUABABBBBABAAABBAAB...ABABBBABAABBABABBABAAAB?AABAAAB'

Test #40:

score: 0
Accepted
time: 3ms
memory: 3572kb

input:

999999772 1000 344 1000
18837 K
4481033 B
4529357 K
6128179 A
6601050 R
8109552 K
9772940 B
10220284 K
10999435 R
11329150 A
11403845 A
12252966 D
13267694 K
13972066 R
14266048 A
14855922 A
15363070 R
15873522 A
17148247 A
17673436 D
18171113 A
20372232 A
20644551 B
20706121 B
22965296 A
24449779 B...

output:

BRDAABRRRABBAAAAAAADRBRARRAARDRRBARBAARBBARABABABAABBAAARRRDARKABARABBAAADBABDAAAAAAABRAKBABRRBAAABAKBBKABAABKKRRAARAARRAARBADAKRRRRRAAAAAARRRRRBADBKARRBARRARAAAARBAABABRAARAAAABRRBABRRKRKDDARDRAARBKARAAADBARABAAARAABBAADAAADRRAAAADAAABBBRAAARRDARRARBRDAAKBABBBARRAABAAABRRRDRABRBAABBBRADBDAARAARRADA...

result:

ok single line: 'BRDAABRRRABBAAAAAAADRBRARRAARD...AADRKBBRBRDRABAAAAAAAABABBBABAB'

Test #41:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

999999778 1000 357 1000
1347983 R
1588187 D
1745578 R
2610124 A
3119286 K
4645662 R
4897444 B
8805042 A
9863663 B
12400448 A
12964259 A
13993266 A
14221549 A
15965026 A
16443278 D
16923171 K
24293952 A
25059735 D
25384477 A
28397468 B
30396485 R
31737363 K
31827634 B
32415862 B
33753007 A
34855878 A...

output:

BARAAAABARAAABRBBBRAAAAABRRRBBRAABAAAAARBBRRRAABAAKRBRRAAABRRAAAARABAAAARDARAABBABBABABARBRAAAARARAAABABAABBAAAABABRBBAAABKABBABRARRBARARAARRRBADARAAAAAAAAAABABABAAABBBBABBAADAABBABARARBKBAAARABRRRRAABAAABAARRBABBBAAARKAAABARBARABDBRBARAAABABBAAARKRBDAABBARKABRAAARARAABAADBBAARRAARAAABBAAABRRAAARADA...

result:

ok single line: 'BARAAAABARAAABRBBBRAAAAABRRRBB...AARRBRRBABAABAAABRBARBBARBBAARB'

Test #42:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

999999979 10 331 1000
47 U
87 I
127 W
345 G
456 N
550 D
581 I
594 V
772 R
963 A
27 1
3054897 3054063
8763627 8761436
12797258 12795274
15055050 15054066
18863130 18862081
21845437 21844830
25045541 25043175
30068559 30066930
31456467 31456006
31490120 31489421
36399896 36399628
42343600 42342450
451...

output:

W?V?????????W??GV?UW??W?W?????WW??VUUW?W??WV???U?W??W???V??WV??????????????????UW???WU??V????U?U????????WWWW?U??U?V?W?WV?V?W??V???UU?U?V????U?VU???N???U?W?W???????V?V??WU?W????????W??????IW??VU????????U???V???V????V?UV??W??WWWU????V?????V???U????W??W???GWV????V?????W?VW?W????V?VN?V???VU?W??????UU??V...

result:

ok single line: 'W?V?????????W??GV?UW??W?W?????...V??U?????????V?UWU?U?????U???V?'

Test #43:

score: 0
Accepted
time: 2ms
memory: 3716kb

input:

999999039 100 352 1000
21603 W
36146 F
48238 H
50645 W
57164 P
63147 S
66591 E
68913 M
69497 Y
88641 G
112447 W
113341 G
120494 J
145586 L
156977 O
182540 T
186209 W
200547 I
216719 I
219445 E
229491 O
238813 C
241317 K
246497 Q
307724 N
309213 U
319315 I
342924 O
346968 R
367315 N
381423 L
384075 V...

output:

?XYUBXVYXSWYK?WK?WVYVVYU?W?DTSYD?XTXRXWWYU?YYYYOVWGYGIVRVYHXW?Y?YY??G?XUVXEU?VW?X?LYXW?UX?UYW?YUYWUVWU?KVXXXYWXWWYB??VYSWXVY??WVUXLJYUWDWXWYWVVR?VYNYVW?WW?XUOXXUURJRWX?UTBYYSY?WFAVVUYWVUXXV?SXUV?KYKWUB???XVVSO?YX?W?IKXXWUVUX?XW?Y?YVWWXYYUVU?VX?UXVU?WTWNUOYB?VUWYWVY?YWVU?V?V???YYJUVVMY?XUMX?QYWVMY?WP...

result:

ok single line: '?XYUBXVYXSWYK?WK?WVYVVYU?W?DTS...W?WW??WYNX?YYXU?VXVXWUQWVUYYDVD'

Test #44:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

134 10 76 33
2 D
5 B
8 C
49 C
53 C
61 B
67 B
71 C
120 D
131 A
2 0
3 2
4 0
7 5
8 6
9 0
13 5
14 13
15 0
19 15
21 0
24 15
27 25
28 4
29 6
30 26
31 21
33 15
34 12
37 0
40 3
42 0
46 38
47 7
50 48
52 7
53 43
55 24
56 24
58 16
59 0
63 29
64 52
66 57
67 47
71 65
72 13
73 50
74 50
75 42
76 46
78 22
79 65
80 ...

output:

??B?CC?B??C?D?B?CD??B??C??DBC??C?

result:

ok single line: '??B?CC?B??C?D?B?CD??B??C??DBC??C?'

Test #45:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

182 14 91 45
2 B
9 A
11 A
14 B
53 B
57 A
61 B
75 A
79 C
95 B
124 C
127 A
141 D
171 A
2 0
4 0
8 0
10 9
12 0
16 0
20 10
21 0
24 6
25 18
26 0
31 26
33 3
35 26
37 14
38 1
40 35
41 15
42 30
45 44
46 9
48 26
50 30
53 13
54 6
55 28
57 11
58 55
59 0
63 0
69 18
70 34
71 20
73 69
76 23
77 11
79 52
80 21
81 22...

output:

A???D?A?????CA??B??????D???C??DCA??CDC?C??CDA

result:

ok single line: 'A???D?A?????CA??B??????D???C??DCA??CDC?C??CDA'

Test #46:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

144 12 80 36
4 A
23 C
26 C
56 B
60 C
80 D
101 D
120 D
132 D
134 D
138 A
139 C
2 0
3 1
4 0
9 2
10 1
12 0
17 7
18 0
21 12
22 6
23 2
25 0
27 0
33 4
34 5
35 8
36 32
37 15
38 6
39 0
42 0
45 0
49 15
50 40
51 0
55 0
58 39
59 25
61 12
62 54
63 0
67 20
68 46
69 2
73 32
74 11
75 16
76 29
78 33
79 52
81 22
82 ...

output:

?????CDDDC??D?????DD???D???CC????CA?

result:

ok single line: '?????CDDDC??D?????DD???D???CC????CA?'

Test #47:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

182 18 96 45
12 A
17 D
28 C
64 B
86 B
87 A
100 B
102 A
109 C
111 D
114 C
131 D
145 B
148 B
158 A
159 A
166 B
172 C
3 1
4 2
5 4
6 0
10 0
14 9
15 0
19 18
21 7
22 1
23 7
24 3
25 11
26 17
28 24
29 4
32 16
33 23
35 0
38 27
39 0
42 12
44 2
45 1
46 12
48 11
51 33
52 46
53 23
55 35
58 16
59 34
61 0
67 53
68...

output:

?ADC?AC???CCA???BB?A???C???C???AABA?BAACCBA?D

result:

ok single line: '?ADC?AC???CCA???BB?A???C???C???AABA?BAACCBA?D'

Test #48:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

126 8 78 31
48 D
50 D
60 C
66 A
70 D
73 A
95 B
124 A
2 0
3 0
5 3
6 0
8 7
9 0
10 0
12 10
13 0
15 10
16 1
17 13
20 7
21 0
23 18
24 21
25 1
26 20
27 12
28 7
29 6
30 5
31 18
32 2
33 16
34 17
36 31
37 0
41 0
46 43
47 0
49 15
51 34
54 29
55 54
56 9
57 27
58 0
61 58
64 28
65 26
67 0
73 58
75 44
76 19
77 39...

output:

??A???A?A????????BAA???????????

result:

ok single line: '??A???A?A????????BAA???????????'

Test #49:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

100 10 63 25
4 C
16 C
34 B
40 C
47 C
48 D
60 D
63 A
65 B
73 D
3 0
4 1
5 2
6 0
7 0
10 5
12 6
13 7
14 2
15 0
19 11
20 15
22 11
23 15
24 17
25 12
26 9
27 26
29 8
31 0
33 14
34 14
35 34
37 14
39 12
40 38
41 3
42 26
43 11
44 42
45 4
46 29
47 0
51 47
52 3
53 10
56 49
57 22
59 24
61 10
62 6
63 3
64 52
66 6...

output:

?B??CD?CCBBABDB?B?DB?D???

result:

ok single line: '?B??CD?CCBBABDB?B?DB?D???'

Test #50:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

115 5 62 28
42 C
60 A
61 A
79 B
107 C
3 0
8 0
10 9
11 6
13 5
14 10
15 11
17 1
18 1
20 9
21 11
22 0
26 1
28 22
30 18
31 24
33 0
37 26
38 10
39 17
41 0
44 35
45 19
47 35
48 3
50 12
51 12
52 47
54 21
55 0
59 51
61 40
62 0
64 42
66 12
67 0
71 45
72 1
73 67
75 22
76 35
77 6
78 58
80 16
81 11
82 45
83 65
...

output:

?A??????????BCBBBC?C?A??C?A?

result:

ok single line: '?A??????????BCBBBC?C?A??C?A?'

Test #51:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

164 14 82 41
5 D
16 A
44 A
46 D
60 A
77 D
81 C
94 A
95 C
97 A
123 A
146 B
159 C
162 D
2 0
3 0
6 2
7 5
8 2
10 4
11 0
12 10
13 1
14 0
17 0
21 15
22 11
23 12
24 18
25 8
26 0
30 0
34 21
35 0
38 9
40 0
44 37
45 32
46 42
49 11
50 17
51 36
53 34
54 0
60 26
62 49
65 47
66 39
68 46
70 15
72 56
76 18
77 36
80...

output:

???????ADD?DA???DAB?C?A???CC???C????BDA??

result:

ok single line: '???????ADD?DA???DAB?C?A???CC???C????BDA??'

Test #52:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

129 7 65 32
10 A
18 C
23 A
38 A
72 C
94 D
108 D
2 0
7 0
10 0
14 10
16 0
19 18
20 14
21 4
23 8
25 17
26 14
28 0
31 6
32 25
33 0
36 21
37 32
38 8
39 0
45 11
47 26
49 43
50 19
51 28
53 0
59 0
64 0
69 12
71 55
72 57
73 33
75 35
77 28
79 3
81 5
82 9
85 0
91 60
92 65
93 50
95 92
96 29
99 71
100 39
101 33
...

output:

?A?C?????????C??DCA?????????????

result:

ok single line: '?A?C?????????C??DCA?????????????'

Test #53:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

131 12 83 32
3 B
23 C
38 B
41 D
55 B
57 B
58 D
62 C
71 B
80 B
94 C
101 D
3 0
5 1
6 0
9 0
12 9
13 11
14 7
16 4
17 4
18 15
19 13
20 17
21 4
22 12
23 22
25 0
29 1
30 20
32 14
33 6
34 27
35 28
37 35
39 2
40 31
41 13
42 41
43 19
45 26
46 3
48 25
49 11
51 11
52 48
53 11
54 13
55 1
56 19
57 0
60 24
61 0
66...

output:

DB??B???C???DD?B?C????B?B?C???BC

result:

ok single line: 'DB??B???C???DD?B?C????B?B?C???BC'

Test #54:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

1953 58 337 488
30 A
34 C
58 C
60 A
73 A
201 B
228 B
285 A
297 B
339 A
377 C
391 B
451 A
492 B
509 A
587 C
594 A
654 B
697 C
800 C
829 C
831 A
865 B
868 A
896 B
934 A
958 A
964 B
1021 A
1069 A
1099 C
1117 C
1193 B
1201 B
1236 C
1285 A
1295 A
1344 A
1402 B
1532 B
1535 A
1545 A
1552 C
1621 A
1631 C
16...

output:

BBCAAAABCCCACCABBBACCABBCAACABABCCBCCCBCBBCACABABCBCBBBBCCCBCACCACBABACABABABCBCCACCACBACBBCAAAAAAACCCCABBCAAACACAAACCAABCBCCACACBABAABBCACAAAAABBBAABBCBBCCCACAAAABCABCBAABCACBBCABBAAABBCCBCBCBBACBBACBCBBBBABBBCCCCBBABBBACCABCCBAABCABABBBBCABBBCBAAACBCABABCABAAABCABCCBACABABABCCCBABBBAAABBBCBCAABAAA...

result:

ok single line: 'BBCAAAABCCCACCABBBACCABBCAACAB...CBCBABCCBCBAABABBBCCACABBBBAAAA'

Test #55:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

1693 54 302 423
5 A
60 A
102 C
117 C
137 C
141 A
155 B
185 B
186 A
210 C
288 C
321 C
395 C
435 B
458 A
512 C
548 C
597 C
628 C
644 A
655 B
657 C
717 C
733 B
744 C
786 B
799 C
816 C
875 B
881 C
925 B
927 B
958 C
981 B
1030 C
1073 A
1097 B
1121 B
1139 A
1163 C
1170 B
1190 A
1206 B
1215 C
1297 B
1345 B...

output:

AACCCBABACABBBBCACCCBCAABBCBCCCCCBAABABAAAACCABCCACCABABABAACCBACCAAAAABBBBCABBAAABACBBBCBBCCACCBCBBAAAAAABBCCBCAABACBCACBCCAAAABBCACABABBCAACBBCCACAAACBCCACABBBCCCAABBCBAABACBCAABABCAABBBCCACABBABBBACBBBBACCBCBBBACCBBBCABAABBACBABCABAAACCCCCABABBCCBAABCCCACABBCACBBBBBBBAAACCCACACCBABCACBACCCCCBABCC...

result:

ok single line: 'AACCCBABACABBBBCACCCBCAABBCBCC...CBBACBCACCBAACCACCCCCCCAAABABBC'

Test #56:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

1978 49 338 494
44 A
45 A
47 A
85 B
93 C
126 C
205 B
298 A
332 A
336 C
360 A
425 C
452 A
464 C
474 C
560 B
561 B
627 B
666 A
718 A
794 A
841 C
901 A
936 B
993 A
1002 C
1020 A
1052 A
1067 C
1158 B
1185 A
1279 B
1294 A
1343 B
1356 C
1366 A
1394 A
1430 C
1449 B
1469 C
1488 A
1495 A
1516 B
1521 A
1670 A...

output:

AABCABCBCBBCBABBABCBABCABBBBBBCBCCCACACBBACCAAACCBCACACAABBCBACCACABBBBAAABBBBABBBACAABBCBBBACBABBCABCABCBCACBBCACCBCCAACABBCCCAAABCACBBCCABAAABBBBCCBCACBCACCBCACCCCBCCCCAACCCABAACBBBBCABCBCCAAACBCABACBCACBABCCBCBABABABBBABCCCACBACACCBBBAABABCBCBAAABCCBAACCBAACBACBCCAABAAACBAAACCACACCBBAABACCCCCBBBA...

result:

ok single line: 'AABCABCBCBBCBABBABCBABCABBBBBB...ACACAABACBABCBCACCAABCABCABBAAB'

Test #57:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

1793 54 313 448
11 B
42 B
56 C
64 A
88 C
125 C
132 C
206 B
220 A
245 C
272 B
311 B
331 C
334 A
361 B
417 A
483 A
487 B
491 C
496 C
511 B
536 A
576 C
640 C
677 A
706 C
787 C
808 B
811 A
824 B
846 C
902 A
937 C
994 C
1045 B
1048 C
1072 C
1080 C
1123 A
1124 C
1160 C
1208 C
1227 A
1243 A
1259 B
1308 C
1...

output:

CCCCBAACAABCBBCBBCABABABAACABBBCBCACBBACACCABABABBBBABCBBCACCBCCCAAABCBBBCACBCBAAAACBCBCBBBAACBACBCCBACCCBCCCBCABACABABCABAACCCBCBCCBCCBACBCABBBACBAACBBAAABCCBCCCBABBBCBABABCBCABACCBABCBABAACCBAABABBCBAABCBCBBCCABBACCBBCCBBAACABACBBCBBCCBCCABBCCAACACBCAACBCCCABBCACAABCBBCAAAABBCCBACABBBCBBBACAACBBCB...

result:

ok single line: 'CCCCBAACAABCBBCBBCABABABAACABB...BCCACAABACBACCAABBCCCAABCABAABB'

Test #58:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

1996 59 343 499
13 B
69 B
87 B
156 A
182 B
226 B
305 A
321 A
394 B
441 B
448 B
451 A
463 C
499 C
586 A
592 B
599 A
600 C
625 C
733 A
768 B
769 B
776 C
877 A
952 B
972 C
1001 A
1008 B
1086 B
1122 B
1176 C
1195 A
1204 C
1265 A
1272 A
1284 B
1301 C
1321 C
1385 C
1426 A
1465 B
1468 B
1487 B
1517 C
1531 ...

output:

CCAAACCACCACBCBBCBBCAAACBCCAACBACBBCBCACBCABACCBCBCBBACAACCCCABAABCBCBBCABBAACBCBCAACBBCBCBBBAAABBBACAACBAAABABBCCCACACBBCBCBBBAABBACCBABBABACACCABABCCBCBABBBABCBACAABCBACABACACACBCCAABCABAABBACCAACCAACAABCCBACCBBAACABBBAABBAABAAABCCCCCAACCACCBBCBCCCCBBBBCCBCAAABBBBCBACCBBCBBABCAABCBBCBCBCAAAACACABC...

result:

ok single line: 'CCAAACCACCACBCBBCBBCAAACBCCAAC...AACBCBCCCACCAACCACAAACACCABACCB'

Test #59:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

1893 63 786 473
19 C
24 C
46 A
96 K
123 I
175 J
200 D
210 I
211 D
273 F
286 E
311 I
343 F
376 E
398 J
438 F
449 H
543 C
607 D
611 F
612 B
627 K
628 C
643 D
648 H
660 F
686 G
698 C
711 A
714 A
742 D
751 I
765 I
844 A
851 E
873 E
924 G
938 I
944 K
1013 C
1019 H
1048 F
1049 B
1144 H
1158 K
1177 C
1222 ...

output:

G?CE?J?KIH?FEGBKGGB?F?FJ?EABIE?ICIB??JJFAAHBAG??CCFEJIBHIBCBACC?F??F??K??JD?FIAH?AE?A?I??C?BEECAJC???I?IC?FFBJBDJCAA?H?EIIFAH?AIGH?FF?EFADI?E?B?J?G?F?JKGBB?GE??F?B?????C?IHHKHAJE????E??AHIJ??JBI?CEB?EA?KIK?CA?G????I???DH??H?DIECBF?EB??CJ?BA?B??I?AD???HCK???EGBGHJJEI?JECIHK?AI?C??FKKHB?G??GIABFEG?IGH...

result:

ok single line: 'G?CE?J?KIH?FEGBKGGB?F?FJ?EABIE...BH??JAKJ?HJJHBH?AKHC?DCHF?FJ?IE'

Test #60:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

1782 57 759 445
8 B
73 A
110 F
121 K
127 A
143 D
154 E
157 C
161 K
204 D
232 B
265 H
280 B
346 G
365 K
379 D
411 K
522 H
563 J
583 F
606 I
630 E
646 A
673 I
674 D
714 I
721 D
741 E
747 J
774 K
822 I
830 C
885 B
927 I
929 C
952 I
955 G
997 D
1022 D
1056 J
1074 A
1095 F
1162 H
1247 A
1253 J
1269 E
130...

output:

FIDI?K??BEG?JJJ?K????FIFB???FGEJ?CFDHHKJAFD?DBH?GA?E??J?IBJ?H???I??E?HJGE?KJABHF?J?FF?EB?F?K?E?HHC???GH?B?AD?B?H?EHB?CEBH??BB??KACHI?A??C?G?EAH???GK?BBKJ????ADIB?K?KCIAFB?KD??KGBDB?II?G?DB?HF?EIJH??CG??J?JJIJ?GC??GE?CGDFAIHA?A???IEEGI?GB?IIHE?JFD????B?B??KFB???G??DK?KKKC???K??J??IAHBJ?????CDKBJBG??K...

result:

ok single line: 'FIDI?K??BEG?JJJ?K????FIFB???FG...??IAAC?FEFKCEBFHJB?BC?FF?KD?AAK'

Test #61:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

1865 61 788 466
8 I
12 C
181 B
198 F
237 K
255 A
261 G
289 A
295 H
330 C
364 J
380 E
414 K
429 B
468 C
528 H
537 I
557 B
600 E
602 I
628 G
648 B
767 H
780 B
789 K
801 J
812 G
846 K
873 D
915 I
941 K
945 D
947 D
950 A
977 B
1031 J
1059 I
1087 E
1088 I
1159 A
1164 A
1180 B
1245 A
1291 I
1349 H
1403 G
...

output:

C?B?KG?GK??KK?BFDGC??JEJ??CAA???B?KD??A????GE??FJ?AG?BHI??KHD????HI??GGII?IG?C?A?AFI?G?KEICB?HACI?E???G?I????DG?C?K?IF?KJFHKJGD?JB?F?CEAKAB????G??CHC?C?E?G????DH?BEHHIDKED?EEA??H??A?EBB?EGAJ?????FHGA?E??GC?J?BF?IAB???ICF??HB??D??B?JIH?E?B?D?CEG????B???HIIEBBK?G???H?????JH?G?DEII?F?KJ?GBEAIF???AJEGK?...

result:

ok single line: 'C?B?KG?GK??KK?BFDGC??JEJ??CAA?...GDEICKGG??K?GEH??I?D??CD??D?G?H'

Test #62:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

1849 59 783 462
14 J
72 B
119 H
206 A
246 H
248 H
255 E
319 E
324 D
339 E
398 H
438 D
461 H
492 J
532 B
576 G
594 B
602 E
606 I
652 H
687 H
688 H
705 J
710 F
713 K
758 G
794 A
813 I
866 E
870 E
875 F
897 K
940 H
1002 A
1012 I
1188 K
1191 I
1205 E
1284 H
1309 I
1310 K
1343 I
1411 H
1424 B
1428 I
1442...

output:

D??E?I??HHEHE?HBI??EDFHK???FDAK??B?GHB?D?HKBIADFFHEHK?KBHAEIHK?H?ID?IFBAEEH?BHEBDAED?K?A?????FF?JDJ??B?F??K?H?BD???DFBKIC?JCAIG??E??F??F??H?DE???HAED??B?HAIHFJ?B?G?F??HD??IC??D??KK?H?HJJ?HAAAGIAFDHAI?FB??BEEBABK?E?K?HHBJHA?EE??HJFA?BF?DEEH?H?AD???BIIHD?GAE???HIIHF?BK?B???HEH??IHH??E????GCHKGEAED?BI?...

result:

ok single line: 'D??E?I??HHEHE?HBI??EDFHK???FDA...A??GBD??E?H?AFA?H?B???ID????BHF'

Test #63:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

1632 52 712 408
356 D
358 F
361 K
387 K
480 I
514 G
523 J
525 I
527 D
582 A
619 G
661 I
667 G
675 H
681 A
703 F
719 B
723 A
815 E
848 C
863 E
876 B
949 A
964 F
1003 J
1026 D
1035 G
1046 B
1066 J
1138 E
1187 K
1200 H
1211 K
1219 I
1263 K
1270 E
1279 B
1301 H
1306 H
1339 I
1368 A
1418 E
1432 E
1496 D
...

output:

??EGEE?D?IK?E???K?KFEA???H??J?GEEJA?EGECF?D?CHEEKAA???FIEGKKI??J?G?EBEFFA??G??DEE???EA???ID?B?H?H?A?IEBHEHGE?BD???B??KBFE?KKB?EF??I?IEK?HIAK?A?EEF?BDJF?D????DE??HK?A??G?DK?I?AJ??G?K?JD??KAD??BA?I?H?????JD??????FDFGDJE?E?F?FK?D?I????FAKIBEEFFEFIDB?D?CAEKHII?ADII?EJ?FADF?CB?J??A???A????JGF??FI?IFFD?BD...

result:

ok single line: '??EGEE?D?IK?E???K?KFEA???H??J?...E?G???EE?ED???JF?ABEGEFFD???JJD'