QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#792167#9279. Matrix 4bulijiojiodibuliduo#WA 9ms3988kbC++173.0kb2024-11-29 03:01:412024-11-29 03:01:42

Judging History

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

  • [2024-11-29 03:01:42]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3988kb
  • [2024-11-29 03:01:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

array<ll,2> operator + (array<ll,2> a,array<ll,2> b) {
	return {a[0]+b[0],a[1]+b[1]};
}
array<ll,2> operator - (array<ll,2> a,array<ll,2> b) {
	return {a[0]-b[0],a[1]-b[1]};
}
array<ll,2> operator * (array<ll,2> a,ll c) {
	return {a[0]*c,a[1]*c};
}
ll p,q,r,s;
int M=1000000000;
bool solve() {
	scanf("%lld%lld%lld%lld",&p,&q,&r,&s);
	if (p*s-q*r!=1) return false;
	if ((p-1)%4!=0||(s-1)%4!=0) return false;
	if (q%2!=0||r%2!=0) return false;
	array<ll,2> a{p,r},b{q,s};
	vector<string> opr;
	auto opB=[&](int tt=1){
		a=a+b*(2*tt);
		if (tt==1) opr.pb("B");
		else opr.pb("(B)"+to_string(tt));
	};
	auto opA=[&](int tt=1){
		b=b+a*(2*tt);
		if (tt==1) opr.pb("A");
		else opr.pb("(A)"+to_string(tt));
	};
	auto opa=[&](int tt=1){
		b=b-a*(2*tt);
		if (tt==1) opr.pb("a");
		else opr.pb("(a)"+to_string(tt));
	};
	auto opb=[&](int tt=1){
		a=a-b*(2*tt);
		if (tt==1) opr.pb("b");
		else opr.pb("(b)"+to_string(tt));
	};
	auto sgn=[&](ll a) {
		return a>0?1:(a==0?0:-1);
	};
	auto gaoop=[&](string a,ll t) {
		if (t<=M) opr.pb("("+a+")"+to_string(t));
		else {
			string v1="(("+a+")"+to_string(M)+")"+to_string(t/M);
			if (t%M!=0) v1+="("+a+")"+to_string(t%M);
		}
	};
	while (b[0]!=0) {
		//printf("! %lld,%lld %lld,%lld\n",a[0],a[1],b[0],b[1]);
		if (abs(a[0])>abs(b[0])) {
			if (sgn(a[0])==sgn(b[0])) {
				if (abs(a[0])>=2*abs(b[0])) {
					opb(abs(a[0])/(2*abs(b[0])));
				} else if (abs(a[0])>=4*abs(a[0]-b[0])) {
					auto dt=a-b;
					ll t=abs(a[0])/abs(a[0]-b[0])/4;
					gaoop("AbAb",t);
					a=a-dt*t*4; b=b-dt*t*4;
				} else {
					opb();
				}
			} else {
				opB();
			}
		} else {
			if (sgn(a[0])==sgn(b[0])) {
				if (abs(b[0])>=2*abs(a[0])) {
					opa(abs(b[0])/(2*abs(a[0])));
				} else if (abs(b[0])>=4*abs(b[0]-a[0])) {
					auto dt=b-a;
					ll t=abs(b[0])/abs(b[0]-a[0])/4;
					gaoop("BaBa",t);
					a=a-dt*t*4; b=b-dt*t*4;
				} else {
					opa();
				}
			} else opA();
		}
	}
	assert(a[0]==1&&b[1]==1);
	if (a[1]>0) {
		gaoop("b",a[1]/2);
	} else if (a[1]<0) {
		gaoop("B",-a[1]/2);
	}
	reverse(all(opr));
	string s;
	for (auto o:opr) s+=o;
	puts(s.c_str());
	// [p,r], [q,s]
	return true;
}

int _;
int main() {
	for (scanf("%d",&_);_;_--) {
		if (!solve()) {
			puts("Impossible");
		}
	}
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3980kb

input:

3
-7 4 -2 1
25 12 -48 -23
-1 0 0 1

output:

(a)2B
(B)1(a)6b
Impossible

result:

ok ok

Test #2:

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

input:

10
1 8 0 1
-7 2 -4 1
1 10 0 1
1 8 0 1
1 6 0 1
-7 2 -4 1
1 8 0 1
-3 2 -2 1
9 2 4 1
5 2 2 1

output:

(a)4
aBB
(a)5
(a)4
(a)3
aBB
(a)4
aB
a(b)2
ab

result:

ok ok

Test #3:

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

input:

10
-7 -4 6 5
9 -8 8 9
-3 4 -10 -3
-3 -4 0 -7
5 -2 8 -7
9 6 10 5
-11 8 2 -3
1 8 -10 1
-7 4 -4 5
1 10 0 -3

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible

result:

ok ok

Test #4:

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

input:

10
-5 7 2 -3
-7 1 -1 0
-4 -7 1 2
-8 -1 -1 0
3 -10 -1 3
-1 6 0 -1
6 -1 -1 0
-7 8 -1 1
-1 9 0 -1
3 -5 1 -2

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible

result:

ok ok

Test #5:

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

input:

10
4 -3 0 -5
-9 -9 -3 -10
-3 -8 1 -4
2 5 -3 -2
5 -1 -7 -3
-7 6 6 9
-5 -2 6 -7
2 -6 2 2
0 4 1 0
-2 -3 0 7

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible

result:

ok ok

Test #6:

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

input:

100
997 998 -998 -999
997 998 -998 -999
-999 -998 998 997
997 -998 998 -999
-999 -998 998 997
-999 998 -998 997
-999 -998 998 997
-999 998 -998 997
-999 -998 998 997
-999 -998 998 997
-999 -998 998 997
997 -998 998 -999
997 998 -998 -999
-999 998 -998 997
-999 998 -998 997
997 998 -998 -999
-999 -99...

output:

(B)1a(BaBa)249
(B)1a(BaBa)249
Ab(AbAb)249
(b)1(AbAb)249A
Ab(AbAb)249
a(BaBa)249B
Ab(AbAb)249
a(BaBa)249B
Ab(AbAb)249
Ab(AbAb)249
Ab(AbAb)249
(b)1(AbAb)249A
(B)1a(BaBa)249
a(BaBa)249B
a(BaBa)249B
(B)1a(BaBa)249
Ab(AbAb)249
(b)1(AbAb)249A
Ab(AbAb)249
a(BaBa)249B
(B)1a(BaBa)249
(b)1(AbAb)249A
a(BaBa)24...

result:

ok ok

Test #7:

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

input:

100
997 998 -998 -999
465 -464 -466 465
-215 -214 -216 -215
-999 1000 998 -999
-999 998 -998 997
-999 998 -998 997
-999 998 -998 997
-999 -1000 -998 -999
-571 -572 572 573
997 998 -998 -999
-331 332 -994 997
749 750 -750 -751
997 -998 998 -999
-995 998 -332 333
997 998 -998 -999
-851 -608 -844 -603
...

output:

(B)1a(BaBa)249
(BaBa)116B
(b)1Ab(AbAb)53
Ab(AbAb)249A
a(BaBa)249B
a(BaBa)249B
a(BaBa)249B
(b)1(BaBa)250
(BaBa)143
(B)1a(BaBa)249
(b)2Ab(AbAb)82A
(B)1a(BaBa)187
(b)1(AbAb)249A
abAb(AbAb)82A
(B)1a(BaBa)249
a(BaBa)30bAb
(b)1(BaBa)250
(b)1(AbAb)249A
(AbAb)42AAb
(b)1Ab(AbAb)249
abAb(AbAb)82
a(BaBa)249B
A...

result:

ok ok

Test #8:

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

input:

100
-207 -206 620 617
997 994 -332 -331
-999 998 1000 -999
-999 -998 998 997
-999 -992 428 425
825 824 826 825
-231 230 232 -231
997 998 -998 -999
-999 998 1000 -999
-999 -998 -1000 -999
-207 208 -208 209
417 -416 416 -415
989 996 -424 -427
941 944 -314 -315
-999 -998 998 997
765 -764 -766 765
-999 ...

output:

(B)1Ab(AbAb)51
A(AbAb)83
(B)1a(BaBa)249B
Ab(AbAb)249
ABAb(AbAb)35
(b)1(AbAb)206
(B)1a(BaBa)57B
(B)1a(BaBa)249
(B)1a(BaBa)249B
(b)1Ab(AbAb)249
(b)1Ab(AbAb)51A
(b)1(BaBa)104B
ABBa(BaBa)35
ABa(BaBa)78
Ab(AbAb)249
(BaBa)191B
Ab(AbAb)249
A(AbAb)20A
A(AbAb)83A
a(BaBa)15ba
AABa(BaBa)49
(B)1(AbAb)83
(a)3(Ba...

result:

ok ok

Test #9:

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

input:

6561
0 0 0 0
1 0 0 0
-1 0 0 0
0 0 0 1
0 0 0 -1
0 0 1 0
0 0 -1 0
0 1 0 0
0 -1 0 0
1 0 0 1
1 0 0 -1
-1 0 0 1
-1 0 0 -1
0 0 1 1
0 0 1 -1
0 0 -1 1
0 0 -1 -1
0 1 1 0
0 1 -1 0
0 -1 1 0
0 -1 -1 0
1 1 0 0
1 -1 0 0
-1 1 0 0
-1 -1 0 0
1 0 1 0
1 0 -1 0
-1 0 1 0
-1 0 -1 0
0 1 0 1
0 1 0 -1
0 -1 0 1
0 -1 0 -1
1 0...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Im...

result:

ok ok

Test #10:

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

input:

10000
0 0 0 0
1 0 0 0
-1 0 0 0
0 0 0 1
0 0 0 -1
0 0 1 0
0 0 -1 0
0 1 0 0
0 -1 0 0
1 0 0 1
1 0 0 -1
-1 0 0 1
-1 0 0 -1
0 0 1 1
0 0 1 -1
0 0 -1 1
0 0 -1 -1
0 1 1 0
0 1 -1 0
0 -1 1 0
0 -1 -1 0
1 1 0 0
1 -1 0 0
-1 1 0 0
-1 -1 0 0
1 0 1 0
1 0 -1 0
-1 0 1 0
-1 0 -1 0
0 1 0 1
0 1 0 -1
0 -1 0 1
0 -1 0 -1
1 ...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Im...

result:

ok ok

Test #11:

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

input:

10000
10 10 10 10
10 10 10 -10
10 10 -10 10
10 10 -10 -10
10 -10 10 10
10 -10 10 -10
10 -10 -10 10
10 -10 -10 -10
-10 10 10 10
-10 10 10 -10
-10 10 -10 10
-10 10 -10 -10
-10 -10 10 10
-10 -10 10 -10
-10 -10 -10 10
-10 -10 -10 -10
9 9 9 9
9 9 9 -9
9 9 -9 9
9 9 -9 -9
9 -9 9 9
9 -9 9 -9
9 -9 -9 9
9 -9 ...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Imp...

result:

ok ok

Test #12:

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

input:

10000
-7 10 2 -3
5 2 2 1
1 2 0 1
-11 6 -2 1
9 2 4 1
1 6 0 1
1 10 0 1
1 2 0 1
-11 6 -2 1
1 0 0 1
-7 4 -2 1
1 0 0 1
5 2 2 1
1 2 0 1
1 8 0 1
5 2 2 1
-3 2 -2 1
9 4 2 1
1 8 0 1
5 2 2 1
1 4 0 1
-3 2 -2 1
5 8 -2 -3
1 2 0 1
-7 2 -4 1
9 2 4 1
-7 2 -4 1
1 2 0 1
5 2 2 1
-3 2 -2 1
-3 2 -2 1
1 8 0 1
-11 2 -6 1
5...

output:

AAbA
ab
a
(a)3B
a(b)2
(a)3
(a)5
a
(a)3B

(a)2B

ab
a
(a)4
ab
aB
(a)2b
(a)4
ab
(a)2
aB
ABa
a
aBB
a(b)2
aBB
a
ab
aB
aB
(a)4
aBBB
ab
aB
(a)5
ABa
(a)2B

(a)2B
(a)3B
(a)3
(a)2B
ABaB
a(b)2
(a)3B

(a)3
aBBB
(a)3
a
a(b)2
(a)2b
aB
(a)3
ABaB
(a)2B
ab
ABaB
a
a
ab
(a)2B
ABa
(a)5
aBB
(a)3
(a)2B
aBB
(a)4
aB
ab
AB...

result:

ok ok

Test #13:

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

input:

10000
-7 8 -6 -3
-3 6 8 -3
9 -10 -8 5
5 2 -4 5
1 -2 10 -3
9 -2 2 1
-3 -6 -4 -11
1 6 10 1
-3 -4 0 -3
9 10 0 -11
-3 6 2 -3
-7 -4 -6 -3
5 4 4 -7
5 6 10 -3
5 0 -10 1
5 4 2 -11
1 10 -2 -3
1 -8 -10 5
-7 4 -10 1
-11 -2 -10 9
-7 -10 -10 1
-7 6 -8 1
1 2 -10 9
5 -2 -4 1
-7 -6 4 -3
9 -2 8 -7
-7 -10 -4 9
5 4 8 ...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Imp...

result:

ok ok

Test #14:

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

input:

10000
5 6 -1 -1
-8 -3 -3 -1
1 -7 0 -1
7 1 -1 0
9 7 -4 -3
-7 4 -2 1
3 10 -1 -3
-1 -4 0 1
8 9 -1 -1
-6 -5 1 1
-5 1 -1 0
-1 5 0 -1
2 -7 -1 3
5 -1 -1 0
-1 9 0 -1
5 7 2 3
4 -1 -1 0
10 -7 -3 2
-1 2 -1 1
4 -7 1 -2
-5 4 1 -1
1 5 0 1
-4 7 1 -2
5 -1 -1 0
-4 -7 1 2
-5 2 -3 1
-9 -2 4 1
-3 8 1 -3
-8 9 -1 1
7 -4 ...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
(a)2B
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossib...

result:

ok ok

Test #15:

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

input:

10000
9 5 7 5
-1 -8 3 -8
-2 3 0 0
3 -2 2 -5
-8 10 -5 -4
0 5 10 -2
5 -6 9 0
-9 -4 -8 -6
8 -8 -8 6
4 9 -9 -6
2 8 4 2
-6 10 -8 3
4 -1 -8 10
-9 4 -9 6
3 6 -6 -3
-8 8 -9 1
6 -4 -4 6
-8 -8 3 -5
-3 10 -8 7
3 -5 4 3
-8 2 4 6
2 -7 -3 -8
9 -4 -10 5
-8 4 -7 10
-9 -1 9 10
0 -10 -6 -8
-5 -8 1 -1
5 10 -8 -4
1 1 -...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Imp...

result:

ok ok

Test #16:

score: 0
Accepted
time: 4ms
memory: 3980kb

input:

10000
-35 96 4 -11
-23 40 4 -7
97 74 38 29
21 26 4 5
41 44 -14 -15
-43 36 -6 5
73 22 -10 -3
-43 32 4 -3
-11 80 -4 29
5 32 2 13
-39 20 -2 1
1 24 0 1
-43 78 -16 29
-75 68 -32 29
-59 44 4 -3
1 86 0 1
17 32 -8 -15
-55 62 -8 9
-27 14 -2 1
-55 32 12 -7
53 16 -10 -3
89 64 -32 -23
-23 40 4 -7
-63 8 -8 1
-43...

output:

AAAABaBA
AAAbbA
abAA(AbAb)1
(a)3(BaBa)1
ABa(BaBa)3
(a)4(BaBa)1B
AAA(AbAb)1b
AAAAABaB
abAbAAAA
ab(a)3
(a)10B
(a)12
abAb(b)2A
aba(BaBa)2B
AAAAAAABaB
(a)43
ABBBBa
(a)3bAb(AbAb)1A
(a)7B
AABaaB
AA(AbAb)1b
A(BaBa)1bAb
AAAbbA
(a)4BBBB
(a)2(BaBa)3B
a(b)3(AbAb)1
(a)8B
(a)12(b)2
AABaBB
AAbAAA
AAAb(AbAb)3A
abA...

result:

ok ok

Test #17:

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

input:

10000
5 40 -94 61
-19 -72 84 -67
69 18 -26 -79
-35 14 76 5
21 -6 84 -91
-59 -90 -12 -27
81 -6 66 9
-7 -48 -38 53
77 30 -70 -71
89 98 -34 -55
-87 -38 46 65
-39 -90 -86 -47
-15 68 64 -87
-55 20 -90 69
61 66 -54 65
73 -30 100 9
-47 -32 -50 53
-71 -94 -16 69
-43 48 82 33
-19 -52 -86 -79
69 26 -38 -7
73 ...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Imp...

result:

ok ok

Test #18:

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

input:

10000
81 20 4 1
-15 -56 4 15
3 2 1 1
-4 -99 1 25
-89 36 42 -17
-13 10 -4 3
-37 -49 3 4
-64 -89 23 32
53 60 15 17
-37 29 14 -11
68 39 -7 -4
-5 48 -2 19
-14 71 -1 5
-15 82 2 -11
35 -24 16 -11
-92 27 17 -5
71 84 -11 -13
-67 -58 15 13
99 14 7 1
-82 49 5 -3
19 77 -1 -4
52 19 -11 -4
21 80 -5 -19
14 -61 -3...

output:

(a)10(b)2
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
AAAAbAAA
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Imposs...

result:

ok ok

Test #19:

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

input:

10000
29 40 -92 50
-4 92 35 46
-55 49 -55 5
70 -75 56 -14
59 -53 5 -30
77 24 -24 5
-88 -51 61 -54
58 -93 59 -64
63 -13 4 87
90 -79 -1 -6
-20 -50 13 55
-26 -35 96 -38
77 91 41 94
-51 -91 -94 -2
77 -81 60 70
-59 15 52 -30
-61 30 -91 -29
-79 63 19 73
64 91 -92 -12
-30 39 -86 -13
-73 78 82 94
-17 6 16 3...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Imp...

result:

ok ok

Test #20:

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

input:

10000
100 100 100 100
100 100 100 -100
100 100 -100 100
100 100 -100 -100
100 -100 100 100
100 -100 100 -100
100 -100 -100 100
100 -100 -100 -100
-100 100 100 100
-100 100 100 -100
-100 100 -100 100
-100 100 -100 -100
-100 -100 100 100
-100 -100 100 -100
-100 -100 -100 100
-100 -100 -100 -100
99 99 ...

output:

Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Imp...

result:

ok ok

Test #21:

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

input:

9853
1 0 0 1
1 -2 0 1
1 0 -2 1
1 2 0 1
1 0 2 1
1 -2 2 -3
-3 -2 2 1
1 2 -2 -3
-3 2 -2 1
1 -4 0 1
1 0 -4 1
1 4 0 1
1 0 4 1
1 -2 -2 5
5 -2 -2 1
5 2 2 1
1 2 2 5
1 -6 0 1
1 0 -6 1
1 6 0 1
1 0 6 1
1 -2 4 -7
-7 -2 4 1
1 4 -2 -7
-7 4 -2 1
-7 2 -4 1
1 2 -4 -7
-7 -4 2 1
1 -4 2 -7
1 -8 0 1
1 0 -8 1
1 8 0 1
1 0...

output:


A
(B)1
a
(b)1
(b)1A
Ab
(B)1a
aB
AA
(B)2
(a)2
(b)2
(B)1A
AB
ab
(b)1a
AAA
(B)3
(a)3
(b)3
(b)2A
Abb
(B)1(a)2
(a)2B
aBB
(B)2a
AAb
(b)1AA
AAAA
(B)4
(a)4
(b)4
Aba
abA
(b)1aB
(B)1ab
ABa
aBA
(b)1AB
(B)1Ab
(B)2A
ABB
(B)1AA
AAB
a(b)2
(b)2a
(a)2b
(b)1(a)2
AAAAA
(B)5
(a)5
(b)5
(b)1(BaBa)1a
(a)2Ba
(b)2Ab
(b)1Ab...

result:

ok ok

Test #22:

score: 0
Accepted
time: 5ms
memory: 3988kb

input:

10000
-43 -128 42 125
125 -128 42 -43
-43 42 -128 125
125 42 -128 -43
125 128 -42 -43
-43 128 -42 125
125 -42 128 -43
-43 -42 128 125
41 -124 42 -127
-127 -124 42 41
41 42 -124 -127
-127 42 -124 41
-127 124 -42 41
41 124 -42 -127
-127 -42 124 41
41 -42 124 -127
41 -122 -42 125
125 -122 -42 41
41 -42...

output:

Ab(AbAb)10a
ab(AbAb)10A
(b)1a(BaBa)10B
(B)1a(BaBa)10b
ABa(BaBa)10
a(BaBa)10BA
(b)1(AbAb)10AB
(B)1Ab(AbAb)10
(b)1(AbAb)10AA
AAb(AbAb)10
(B)2a(BaBa)10
a(BaBa)10BB
(a)2(BaBa)10B
(B)1a(BaBa)10a
Ab(AbAb)10b
(b)2(AbAb)10A
(BaBa)10BA
A(BaBa)10B
(B)1(AbAb)10A
(AbAb)10AB
ab(AbAb)10
(b)1(AbAb)10a
a(BaBa)10b
(...

result:

ok ok

Test #23:

score: -100
Wrong Answer
time: 9ms
memory: 3748kb

input:

10000
9565 1614 1286 217
8693 1644 -3400 -643
9057 3602 958 381
7741 6150 832 661
6981 4970 -2246 -1599
4621 5368 266 309
-4647 6974 -1328 1993
3113 9234 -504 -1495
-79 1468 12 -223
-4799 1814 918 -347
281 4338 -16 -247
-2639 3814 694 -1003
-5139 4946 -1784 1717
8961 2458 1214 333
7641 2462 -3386 -1...

output:

(a)4BaabAAAAAAAb(b)2
ABaab(AbAb)2A(AbAb)1(b)2
(a)5Ba(a)2BBBBBBBBBab
(a)5BaBBABBB(AbAb)1
AAb(AbAb)2(b)2(AbAb)2bAb
(a)9Bab(a)3Ba(BaBa)1
(a)2Ba(a)165bA
AAABBBab(AbAb)7a
AAABaaBAAAAAAAAA
AA(AbAb)1AAb(a)2bAB
AAAAAAAAAb(a)2Ba(a)7
AAb(b)2Ab(AbAb)3AAAbA
abAb(AbAb)1AAba(BaBa)6B
(a)4BabA(BaBa)1BAbb
ABBa(a)4BA...

result:

wrong output format case 7683: line length exceeds 1024