QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#211392#4273. Good Gamelmeowdn0 58ms50924kbC++143.4kb2023-10-12 15:48:022023-10-12 15:48:02

Judging History

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

  • [2023-10-12 15:48:02]
  • 评测
  • 测评结果:0
  • 用时:58ms
  • 内存:50924kb
  • [2023-10-12 15:48:02]
  • 提交

answer

//vanitas vanitatum et omnia
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128; 
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}      
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii; 
typedef vector<int> vi;  
typedef vector<pii> vp; 
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

const int N=1e6+5;
int n,m,tt,del[N];
struct node {int x,l,r;} a[N];
char s[N];
vp ans,tans;

int Del(int c,int r,int z=N,int d=0) {
  int x=c-1,y=c+1,res=0;
  rep(i,1,r) {
    while(del[x]) x--;
    while(del[y]) y++;
    pii p(a[c].l-(x+1>z)*d,a[c].r-(x+1>z)*d);
    res+=p.se-p.fi+1, ans.eb(p);
    //cout<<"D "<<c<<' '<<x<<' '<<y<<endl;
    a[c].l=a[x].l;
    a[c].r=a[x].r+a[y].r-a[y].l+1;
    del[x]=del[y]=1, x--, y++;
  } return res;
}
bool Getodd(int L,int R) {
  int n=R-L+1;
  int c=L-1+(n+1)/2,l=c,r=c,p=(n+1)/2;
  if(a[c].x==1) {
    Del(c,p-1);
    ans.eb(a[c].l,a[c].r);
    return 1;
  }
  while(l>=L&&!a[l].x) --l;
  while(r<=R&&!a[r].x) ++r;
  if(l<L||r>R) return 0;
  if(r-l>=p) return 0;
  if(r-c<=c-l) {
    int d=Del(l,r-c);
    //rep(i,1,n) if(!del[i]) cout<<i<<" "<<a[i].l<<" "<<a[i].r<<endl;
    //cout<<d<<endl;
    Del(r,p-1-(r-c),l,d);
    ans.eb(a[r].l,a[r].r);
  } else {
    Del(r,p-c); Del(l,p-1-(p-c));
    ans.eb(a[l].l,a[l].r);
  }
  return 1;
}
bool Geteven() {
  static int f[N],pre[N],suf[N],lst[N],nxt[N];
  rep(i,1,n) lst[i]=(a[i].x==1?i:lst[i-1]);
  nxt[n+1]=n+1;
  per(i,n,1) nxt[i]=(a[i].x==1?i:nxt[i+1]);
  rep(i,1,n) if(!a[i].x) f[i]=nxt[i]-lst[i]-1;
  rep(i,1,n) if(i&1) pre[i]=min(i,f[(i+1)/2]);
  rep(i,1,n) pre[i]=(pre[i]==0||pre[i]*2+1<i);
  per(i,n,1) if((n-i+1)&1) suf[i]=min(n-i+1,f[(i+n)/2]);
  per(i,n,1) suf[i]=(suf[i]==0||suf[i]*2+1<n-i+1);
  rep(i,1,n) if((i&1)&&pre[i]&&suf[i+1]) {
    Getodd(i+1,n), Getodd(1,i);
    return 1;
  } return 0;
}

signed main() {
  scanf("%d%s",&n,s+1);
  rep(i,1,n) {
    int l=i, r=i;
    while(r<=n&&s[r]==s[l]) r++; r--;
    //cout<<l<<" "<<r<<endl;
    a[++m]=(node){l!=r,l,r}; i=r;
  }
  n=m;
  //rep(i,1,n) cout<<a[i].x<<" "; puts("");
  if(n&1) tt=Getodd(1,n);
  else tt=Geteven();
  if(!tt) return puts("-1"), 0;
  for(auto [l,r]:ans) {
    if((r-l)&1) {
      for(int x=r-1;x>=l;x-=2) tans.eb(x,2);
    } else {
      tans.eb(r-2,3);
      for(int x=r-4;x>=l;x-=2) tans.eb(x,2);
    }
  }
  printf("%d\n",(int)tans.size());
  for(auto [l,r]:tans) printf("%d %d\n",l,r);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 1ms
memory: 5912kb

input:

9
ABAABBBAA

output:

4
3 2
4 2
2 2
1 3

result:

ok good solution!

Test #2:

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

input:

13
ABABBABABBABA

output:

6
4 2
3 2
5 2
4 2
2 3
1 2

result:

ok good solution!

Test #3:

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

input:

15
AABABAABABAABAB

output:

7
6 2
5 2
7 2
6 2
4 3
3 2
1 2

result:

ok good solution!

Test #4:

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

input:

15
ABAABBBABAABBAB

output:

7
12 2
10 3
9 2
3 2
4 2
2 2
1 2

result:

ok good solution!

Test #5:

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

input:

1
B

output:

-1

result:

ok no solution

Test #6:

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

input:

2
BB

output:

1
1 2

result:

ok good solution!

Test #7:

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

input:

7
AAAABBB

output:

3
5 3
3 2
1 2

result:

ok good solution!

Test #8:

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

input:

11
BBBBBBAAAAA

output:

5
9 3
7 2
5 2
3 2
1 2

result:

ok good solution!

Test #9:

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

input:

2
AB

output:

-1

result:

ok no solution

Test #10:

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

input:

14
BAAAAAAAAAAAAA

output:

-1

result:

ok no solution

Test #11:

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

input:

14
ABBABAABBABBAB

output:

7
8 2
9 2
8 2
6 2
5 2
2 2
1 2

result:

ok good solution!

Test #12:

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

input:

15
BAABABABBABBAAB

output:

6
2 2
6 2
5 2
4 3
3 3
1 3

result:

ok good solution!

Test #13:

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

input:

14
BABBBBBBBBBBAB

output:

7
11 2
9 2
7 2
5 2
3 2
2 2
1 2

result:

ok good solution!

Test #14:

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

input:

15
BABAAAAAAAAABAB

output:

7
10 3
8 2
6 2
4 2
3 2
2 2
1 2

result:

ok good solution!

Test #15:

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

input:

14
BBBABAAAAAAABA

output:

6
10 3
8 2
6 2
5 2
4 2
1 3

result:

ok good solution!

Test #16:

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

input:

15
AAAABABAAAAABAB

output:

7
10 3
8 2
7 2
6 2
5 2
3 2
1 2

result:

ok good solution!

Test #17:

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

input:

14
BAAABABAAAABAB

output:

6
2 3
7 2
5 2
4 2
3 2
1 3

result:

ok good solution!

Test #18:

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

input:

15
ABAAAABABBBBABA

output:

7
5 2
3 2
7 2
5 2
4 2
2 3
1 2

result:

ok good solution!

Test #19:

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

input:

14
BABAAABAAAABAB

output:

6
4 3
7 2
5 2
3 3
2 2
1 2

result:

ok good solution!

Test #20:

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

input:

15
BABBABABBBBBBAB

output:

7
3 2
2 2
8 2
6 2
4 2
3 2
1 3

result:

ok good solution!

Test #21:

score: -3
Wrong Answer
time: 1ms
memory: 5960kb

input:

14
BABAAAABABBBAB

output:

7
6 2
4 2
3 2
2 2
3 2
1 2
0 2

result:

wrong answer Integer 0 violates the range [1, 2]

Subtask #2:

score: 0
Wrong Answer

Test #51:

score: 6
Accepted
time: 0ms
memory: 12192kb

input:

299
ABABABABABABABABABABABABABABABABABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #52:

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

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB...

output:

-1

result:

ok no solution

Test #53:

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

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

149
102 2
100 2
98 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87 2
86 2
85 2
84 2
83 2
82 2
81 2
80 2
79 2
78 2
77 2
76 2
75 2
74 2
73 2
72 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
101 2
99 2
97 2
96 2
95 2
94 2
93 2
92 ...

result:

ok good solution!

Test #54:

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

input:

299
BBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
102 3
101 2
100 2
99 2
98 2
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87 2
86 2
85 2
84 2
83 2
82 2
81 2
80 2
79 2
78 2
77 2
76 2
75 2
74 2
73 2
72 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
105 3
103 2
102 2
101 2
100 2
99 2
98 2
97 2
96 2
95 ...

result:

ok good solution!

Test #55:

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

input:

297
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

148
224 2
222 3
221 2
220 2
219 2
218 2
217 2
216 2
215 2
214 2
213 2
212 2
211 2
210 2
209 2
208 2
207 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
17...

result:

ok good solution!

Test #56:

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

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
209 3
210 2
208 2
207 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
174 2
173 2
172 2
171 2
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
16...

result:

ok good solution!

Test #57:

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

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
209 2
210 2
208 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
174 2
173 2
172 2
171 2
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
161 2
16...

result:

ok good solution!

Test #58:

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

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABBAAAABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
248 2
250 2
248 2
246 2
244 2
243 2
242 2
241 2
240 2
239 2
238 2
237 2
236 2
235 2
234 2
233 2
232 2
231 2
230 2
229 2
228 2
227 2
226 2
225 2
224 2
223 2
222 2
221 2
220 2
219 2
218 2
217 2
216 2
215 2
214 2
213 2
212 2
211 2
210 2
209 2
208 2
207 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
19...

result:

ok good solution!

Test #59:

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

input:

298
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

output:

149
297 2
295 2
293 2
291 2
289 2
287 2
285 2
283 2
281 2
279 2
277 2
275 2
273 2
271 2
269 2
267 2
265 2
263 2
261 2
259 2
257 2
255 2
253 2
251 2
249 2
247 2
245 2
243 2
241 2
239 2
237 2
235 2
233 2
231 2
229 2
227 2
225 2
223 2
221 2
219 2
217 2
215 2
213 2
211 2
209 2
207 2
205 2
203 2
201 2
19...

result:

ok good solution!

Test #60:

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

input:

298
BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

-1

result:

ok no solution

Test #61:

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

input:

297
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

148
296 2
294 2
292 2
290 2
288 2
286 2
284 2
282 2
280 2
278 2
276 2
274 2
272 2
270 2
268 2
266 2
264 2
262 2
260 2
258 2
256 2
254 2
252 2
250 2
248 2
246 2
244 2
242 2
240 2
238 2
236 2
234 2
232 2
230 2
228 2
226 2
224 2
222 2
220 2
218 2
216 2
214 2
212 2
210 2
208 2
206 2
204 2
202 2
200 2
19...

result:

ok good solution!

Test #62:

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

input:

300
AAAABBBBAAAABBBBBBAABBAABBBBAAAAABBBBBAAAABBBBAAAABBBBBBAABBBAAAABBBBAAAABBBBBBAAAAABBAAABBAAABBBBBAAAABBBBAAABBBBAAAAAABBBBAABBAAAABBBBAAABBBBBAAABBBBBAAAABBAAABBBAABBBAAAABBBAAAAAABBBBBBAAABBAAAAAABBBBBAAAAAABBBBAAAAABBBBAAAABBBBBBAAABBBBAAAAAAABBAAAAAAABBBBBAAAABBBBAAAAABBBAAAAABBBAAAABBBBAAA...

output:

139
142 3
140 2
141 2
139 2
137 2
139 3
137 2
135 2
133 2
135 2
133 2
131 2
129 2
129 2
127 2
127 3
125 2
125 3
123 2
121 2
121 2
119 2
117 2
115 2
115 3
113 2
111 2
112 3
110 2
108 2
108 3
106 2
104 2
108 2
106 2
104 2
102 2
100 2
103 3
101 2
99 2
97 2
95 2
96 2
94 2
92 2
92 2
90 2
93 3
91 2
89 2
8...

result:

ok good solution!

Test #63:

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

input:

299
BBBBBBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABABABABABABABABABABABABABABABABABAAAAAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABBBBBBBABABABABABABABABABABABABABABABABABA...

output:

148
107 2
105 2
103 2
101 2
99 2
148 3
146 2
144 2
142 2
140 2
138 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
98 3
97 2...

result:

ok good solution!

Test #64:

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

input:

299
BABABABABABABABBBBBBBBBBABABABABABABABABABABABABABBBBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABAAAAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
126 2
124 2
122 2
120 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99 2
98 2
97 2
96 2
95 2
94 2
93 2
92 2
91 2
139 2
137 2
135 2
133 2
131 2
130 2
129 2
128 2
127 2
126 2
137 3
135 2
133 2
131 2
129 2
127 2
125 2
124 2
123 2...

result:

ok good solution!

Test #65:

score: -6
Wrong Answer
time: 1ms
memory: 6152kb

input:

298
ABABABABABABABABABAAAAABABABABABABABABABAAAABABABABABABABABABABABABABABABABBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAABABABABABABABBBBBBABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABBBBBBABAAAAAABABABABABABABABBBBBBBABABABBBBBBABABABABABABABABABABABABABABABABABABABABABA

output:

146
136 2
134 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
123 3
121 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
103 3
101 2
99 2
98 2
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87...

result:

wrong answer Integer 0 violates the range [1, 12]

Subtask #3:

score: 0
Wrong Answer

Test #102:

score: 7
Accepted
time: 1ms
memory: 6060kb

input:

5998
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

2998
1998 2
1996 2
1995 2
1994 2
1993 2
1992 2
1991 2
1990 2
1989 2
1988 2
1987 2
1986 2
1985 2
1984 2
1983 2
1982 2
1981 2
1980 2
1979 2
1978 2
1977 2
1976 2
1975 2
1974 2
1973 2
1972 2
1971 2
1970 2
1969 2
1968 2
1967 2
1966 2
1965 2
1964 2
1963 2
1962 2
1961 2
1960 2
1959 2
1958 2
1957 2
1956 2
1...

result:

ok good solution!

Test #103:

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

input:

5999
BBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

2998
2003 2
2001 2
2000 2
1999 2
1998 2
1997 2
1996 2
1995 2
1994 2
1993 2
1992 2
1991 2
1990 2
1989 2
1988 2
1987 2
1986 2
1985 2
1984 2
1983 2
1982 2
1981 2
1980 2
1979 2
1978 2
1977 2
1976 2
1975 2
1974 2
1973 2
1972 2
1971 2
1970 2
1969 2
1968 2
1967 2
1966 2
1965 2
1964 2
1963 2
1962 2
1961 2
1...

result:

ok good solution!

Test #104:

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

input:

5998
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2998
4500 2
4499 2
4497 2
4496 2
4495 2
4494 2
4493 2
4492 2
4491 2
4490 2
4489 2
4488 2
4487 2
4486 2
4485 2
4484 2
4483 2
4482 2
4481 2
4480 2
4479 2
4478 2
4477 2
4476 2
4475 2
4474 2
4473 2
4472 2
4471 2
4470 2
4469 2
4468 2
4467 2
4466 2
4465 2
4464 2
4463 2
4462 2
4461 2
4460 2
4459 2
4458 2
4...

result:

ok good solution!

Test #105:

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

input:

5998
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2999
4198 2
4199 2
4197 2
4196 2
4195 2
4194 2
4193 2
4192 2
4191 2
4190 2
4189 2
4188 2
4187 2
4186 2
4185 2
4184 2
4183 2
4182 2
4181 2
4180 2
4179 2
4178 2
4177 2
4176 2
4175 2
4174 2
4173 2
4172 2
4171 2
4170 2
4169 2
4168 2
4167 2
4166 2
4165 2
4164 2
4163 2
4162 2
4161 2
4160 2
4159 2
4158 2
4...

result:

ok good solution!

Test #106:

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

input:

5999
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2999
4197 3
4199 2
4197 2
4195 2
4194 2
4193 2
4192 2
4191 2
4190 2
4189 2
4188 2
4187 2
4186 2
4185 2
4184 2
4183 2
4182 2
4181 2
4180 2
4179 2
4178 2
4177 2
4176 2
4175 2
4174 2
4173 2
4172 2
4171 2
4170 2
4169 2
4168 2
4167 2
4166 2
4165 2
4164 2
4163 2
4162 2
4161 2
4160 2
4159 2
4158 2
4157 2
4...

result:

ok good solution!

Test #107:

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

input:

5998
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2998
4996 3
4996 3
4994 2
4993 2
4992 2
4991 2
4990 2
4989 2
4988 2
4987 2
4986 2
4985 2
4984 2
4983 2
4982 2
4981 2
4980 2
4979 2
4978 2
4977 2
4976 2
4975 2
4974 2
4973 2
4972 2
4971 2
4970 2
4969 2
4968 2
4967 2
4966 2
4965 2
4964 2
4963 2
4962 2
4961 2
4960 2
4959 2
4958 2
4957 2
4956 2
4955 2
4...

result:

ok good solution!

Test #108:

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

input:

5997
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

2998
5995 3
5993 2
5991 2
5989 2
5987 2
5985 2
5983 2
5981 2
5979 2
5977 2
5975 2
5973 2
5971 2
5969 2
5967 2
5965 2
5963 2
5961 2
5959 2
5957 2
5955 2
5953 2
5951 2
5949 2
5947 2
5945 2
5943 2
5941 2
5939 2
5937 2
5935 2
5933 2
5931 2
5929 2
5927 2
5925 2
5923 2
5921 2
5919 2
5917 2
5915 2
5913 2
5...

result:

ok good solution!

Test #109:

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

input:

6000
ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

-1

result:

ok no solution

Test #110:

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

input:

5999
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

2999
5997 3
5995 2
5993 2
5991 2
5989 2
5987 2
5985 2
5983 2
5981 2
5979 2
5977 2
5975 2
5973 2
5971 2
5969 2
5967 2
5965 2
5963 2
5961 2
5959 2
5957 2
5955 2
5953 2
5951 2
5949 2
5947 2
5945 2
5943 2
5941 2
5939 2
5937 2
5935 2
5933 2
5931 2
5929 2
5927 2
5925 2
5923 2
5921 2
5919 2
5917 2
5915 2
5...

result:

ok good solution!

Test #111:

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

input:

5999
BBBAAAABBAAAAAAABBBAAAAABBBBBAABBBAABBBBBAAAABBBBBAAAAABBBAAAAABBBBBAAAAAABBBBBAAAABBBBBBAAAAAAABBBBBBAAAABBBBBAAABBBAAABBBBAAAABBBBAAABBBAAAABBBBAAABBBBAAAABBAAAABBBAAAAAABBBAAABBBBBAAAAABBBBAAAABBBAAABBBAAABBAAAABBAAABBBBBAAAAAABBBBBBBAAAABBBAAABBBAABBBAAAABBAABBBBBBBAAAAAABBBBAAAAABBBBAAABBB...

output:

2806
3035 2
3037 3
3035 2
3033 2
3031 2
3031 3
3029 2
3027 2
3029 2
3027 2
3025 2
3023 2
3025 2
3023 2
3021 2
3020 3
3018 2
3016 2
3017 3
3015 2
3013 2
3011 2
3012 2
3010 2
3008 2
3006 2
3004 2
3004 3
3002 2
3000 2
3002 2
3000 2
2998 2
2996 2
2998 3
2996 2
2994 2
2998 2
2996 2
2994 2
2992 2
2992 3
2...

result:

ok good solution!

Test #112:

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

input:

6000
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

2999
1653 3
1651 2
1649 2
1647 2
1645 2
1643 2
1642 2
1641 2
1640 2
1639 2
1638 2
1637 2
1636 2
1635 2
1634 2
1633 2
1632 2
1631 2
1630 2
1629 2
1628 2
1627 2
1626 2
1625 2
1624 2
1623 2
1622 2
1621 2
1620 2
1619 2
1618 2
1617 2
1616 2
1615 2
1614 2
1613 2
1612 2
1611 2
1610 2
1609 2
1608 2
1607 2
1...

result:

ok good solution!

Test #113:

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

input:

6000
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #114:

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

input:

6000
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

2998
2169 3
2168 2
2167 2
2166 2
2165 2
2164 2
2163 2
2162 2
2161 2
2160 2
2159 2
2158 2
2157 2
2156 2
2155 2
2154 2
2153 2
2152 2
2151 2
2150 2
2149 2
2148 2
2147 2
2146 2
2145 2
2144 2
2143 2
2142 2
2141 2
2140 2
2139 2
2138 2
2137 2
2136 2
2135 2
2134 2
2133 2
2132 2
2131 2
2130 2
2129 2
2128 2
2...

result:

ok good solution!

Test #115:

score: -7
Wrong Answer
time: 2ms
memory: 12196kb

input:

5999
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

5125
3820 2
3818 2
3817 2
3816 2
3815 2
3814 2
3813 2
3812 2
3811 2
3810 2
3809 2
3808 2
3807 2
3806 2
3805 2
3804 2
3803 2
3802 2
3801 2
3800 2
3799 2
3798 2
3797 2
3796 2
3795 2
3794 2
3793 2
3792 2
3791 2
3790 2
3789 2
3788 2
3787 2
3786 2
3785 2
3784 2
3783 2
3782 2
3781 2
3780 2
3779 2
3778 2
3...

result:

wrong answer invalid operation on step #2166: out of bounds

Subtask #4:

score: 0
Wrong Answer

Test #153:

score: 9
Accepted
time: 46ms
memory: 31996kb

input:

999997
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

499998
333332 2
333330 2
333328 2
333327 2
333326 2
333325 2
333324 2
333323 2
333322 2
333321 2
333320 2
333319 2
333318 2
333317 2
333316 2
333315 2
333314 2
333313 2
333312 2
333311 2
333310 2
333309 2
333308 2
333307 2
333306 2
333305 2
333304 2
333303 2
333302 2
333301 2
333300 2
333299 2
33329...

result:

ok good solution!

Test #154:

score: 0
Accepted
time: 43ms
memory: 50164kb

input:

999998
BBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

499998
333338 2
333336 2
333334 2
333333 2
333332 2
333331 2
333330 2
333329 2
333328 2
333327 2
333326 2
333325 2
333324 2
333323 2
333322 2
333321 2
333320 2
333319 2
333318 2
333317 2
333316 2
333315 2
333314 2
333313 2
333312 2
333311 2
333310 2
333309 2
333308 2
333307 2
333306 2
333305 2
33330...

result:

ok good solution!

Test #155:

score: 0
Accepted
time: 36ms
memory: 49632kb

input:

999997
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

499998
749999 2
749997 3
749996 2
749995 2
749994 2
749993 2
749992 2
749991 2
749990 2
749989 2
749988 2
749987 2
749986 2
749985 2
749984 2
749983 2
749982 2
749981 2
749980 2
749979 2
749978 2
749977 2
749976 2
749975 2
749974 2
749973 2
749972 2
749971 2
749970 2
749969 2
749968 2
749967 2
74996...

result:

ok good solution!

Test #156:

score: 0
Accepted
time: 58ms
memory: 50568kb

input:

999998
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

499998
699998 3
699997 3
699996 2
699995 2
699994 2
699993 2
699992 2
699991 2
699990 2
699989 2
699988 2
699987 2
699986 2
699985 2
699984 2
699983 2
699982 2
699981 2
699980 2
699979 2
699978 2
699977 2
699976 2
699975 2
699974 2
699973 2
699972 2
699971 2
699970 2
699969 2
699968 2
699967 2
69996...

result:

ok good solution!

Test #157:

score: 0
Accepted
time: 42ms
memory: 50924kb

input:

999999
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

499999
700000 2
699999 3
699997 2
699996 2
699995 2
699994 2
699993 2
699992 2
699991 2
699990 2
699989 2
699988 2
699987 2
699986 2
699985 2
699984 2
699983 2
699982 2
699981 2
699980 2
699979 2
699978 2
699977 2
699976 2
699975 2
699974 2
699973 2
699972 2
699971 2
699970 2
699969 2
699968 2
69996...

result:

ok good solution!

Test #158:

score: 0
Accepted
time: 52ms
memory: 49916kb

input:

999997
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

499998
833329 3
833329 2
833327 2
833326 2
833325 2
833324 2
833323 2
833322 2
833321 2
833320 2
833319 2
833318 2
833317 2
833316 2
833315 2
833314 2
833313 2
833312 2
833311 2
833310 2
833309 2
833308 2
833307 2
833306 2
833305 2
833304 2
833303 2
833302 2
833301 2
833300 2
833299 2
833298 2
83329...

result:

ok good solution!

Test #159:

score: 0
Accepted
time: 38ms
memory: 11880kb

input:

999999
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

499999
999997 3
999995 2
999993 2
999991 2
999989 2
999987 2
999985 2
999983 2
999981 2
999979 2
999977 2
999975 2
999973 2
999971 2
999969 2
999967 2
999965 2
999963 2
999961 2
999959 2
999957 2
999955 2
999953 2
999951 2
999949 2
999947 2
999945 2
999943 2
999941 2
999939 2
999937 2
999935 2
99993...

result:

ok good solution!

Test #160:

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

input:

999998
BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

-1

result:

ok no solution

Test #161:

score: 0
Accepted
time: 39ms
memory: 16776kb

input:

999998
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

499999
999997 2
999995 2
999993 2
999991 2
999989 2
999987 2
999985 2
999983 2
999981 2
999979 2
999977 2
999975 2
999973 2
999971 2
999969 2
999967 2
999965 2
999963 2
999961 2
999959 2
999957 2
999955 2
999953 2
999951 2
999949 2
999947 2
999945 2
999943 2
999941 2
999939 2
999937 2
999935 2
99993...

result:

ok good solution!

Test #162:

score: 0
Accepted
time: 33ms
memory: 28160kb

input:

999998
AAAAAAAABBBBAAAAAABBAAAABBBAAAAAABBBBBBAAAAABBBBBBAAAABBBAAABBBAAAAAABBBAAABBBBBAABBBBBBAAABBAAAAAAABBBAAAAAAABBBAAAAAABBBBAAABBBAAABBBBBBAAAABBBAAABBBAAAABBBBAABBBBAAAAABBBBBBAAAAAABBBBBAABBBBBBAAABBBBAABBAAAABBAABBBBAABBBBBBAAAAABBBBBBAAAAABBBBAAAAABBAAAAAAAABBAAAABBBBAAABBBBAAAABBBBBAAAABB...

output:

468730
501095 3
501100 2
501098 2
501096 2
501094 2
501092 2
501092 3
501090 2
501088 2
501091 3
501089 2
501087 2
501085 2
501084 3
501082 2
501080 2
501081 3
501079 2
501077 2
501077 3
501075 2
501073 2
501077 2
501075 2
501073 2
501071 2
501071 3
501069 2
501067 2
501068 2
501066 2
501064 2
50106...

result:

ok good solution!

Test #163:

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

input:

999997
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

-1

result:

ok no solution

Test #164:

score: 0
Accepted
time: 46ms
memory: 50672kb

input:

1000000
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

499999
780037 2
780035 2
780033 2
780031 2
780029 2
780027 2
780025 2
780024 2
780023 2
780022 2
780021 2
780020 2
780019 2
780018 2
780017 2
780016 2
780015 2
780014 2
780013 2
780012 2
780011 2
780010 2
780009 2
780008 2
780007 2
780006 2
780005 2
780004 2
780003 2
780002 2
780001 2
780000 2
77999...

result:

ok good solution!

Test #165:

score: 0
Accepted
time: 44ms
memory: 32532kb

input:

999997
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

499996
277685 2
277683 2
277681 2
277680 2
277679 2
277678 2
277677 2
277676 2
277675 2
277674 2
277673 2
277672 2
277671 2
277670 2
277669 2
277668 2
277667 2
277666 2
277665 2
277664 2
277663 2
277662 2
277661 2
277660 2
277659 2
277658 2
277657 2
277656 2
277655 2
277654 2
277653 2
277652 2
27765...

result:

ok good solution!

Test #166:

score: 0
Accepted
time: 52ms
memory: 49612kb

input:

1000000
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

499997
483888 2
483886 2
483885 2
483884 2
483883 2
483882 2
483881 2
483880 2
483879 2
483878 2
483877 2
483876 2
483875 2
483874 2
483873 2
483872 2
483871 2
483870 2
483869 2
483868 2
483867 2
483866 2
483865 2
483864 2
483863 2
483862 2
483861 2
483860 2
483859 2
483858 2
483857 2
483856 2
48385...

result:

ok good solution!

Test #167:

score: -9
Wrong Answer
time: 45ms
memory: 32928kb

input:

999999
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

499994
478917 3
478916 2
478915 2
478914 2
478913 2
478912 2
478911 2
478910 2
478909 2
478908 2
478907 2
478906 2
478905 2
478904 2
478903 2
478902 2
478901 2
478900 2
478899 2
478898 2
478897 2
478896 2
478895 2
478894 2
478893 2
478892 2
478891 2
478890 2
478889 2
478888 2
478887 2
478886 2
47888...

result:

wrong answer Integer 0 violates the range [1, 42182]