QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#513542#8825. Puzzle: SummonPetroTarnavskyi#AC ✓82ms7484kbC++203.4kb2024-08-10 18:11:332024-08-10 18:11:35

Judging History

This is the latest submission verdict.

  • [2024-08-10 18:11:35]
  • Judged
  • Verdict: AC
  • Time: 82ms
  • Memory: 7484kb
  • [2024-08-10 18:11:33]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const int B = 10;

template<typename T>
void updMin(T& a, T b)
{
	a = min(a, b);
}

template<typename T>
void updMax(T& a, T b)
{
	a = max(a, b);
}

struct Big
{
	VI vec;
	Big (int x)
	{
		vec = {x};
	}
	Big(const string& s)
	{
		vec.resize(SZ(s));
		FOR(i, 0, SZ(s))
			vec[i] = s[i] - '0';
		reverse(ALL(vec));
	}
	bool operator<(const Big& a)
	{
		if (SZ(vec) != SZ(a.vec))
			return SZ(vec) < SZ(a.vec);
		RFOR(i, SZ(vec), 0)
			if (vec[i] != a.vec[i])
				return vec[i] < a.vec[i];
		return false;
	}
	void operator+= (const Big& a)
	{
		if (SZ(vec) < SZ(a.vec))
			vec.resize(SZ(a.vec));
		FOR(i, 0, SZ(a.vec))
			vec[i] += a.vec[i];
		for (int i = 0; i < SZ(a.vec) || (i < SZ(vec) && vec[i] >= B); i++)
		{
			if (vec[i] >= B)
			{
				vec[i] -= B;
				if (i + 1 >= SZ(vec))
					vec.PB(0);
				vec[i + 1]++;
			}
		}
	}
	void print() const
	{
		RFOR(i, SZ(vec), 0)
			cout << vec[i];
		cout << "\n";
	}
};


int n;
vector<string> s(2);

pair<Big, vector<string>> f(int x1, int x2)
{
	vector<string> res(2, string(2 * n, '0'));
	int mnX = min(x1, x2), mxX = max(x1, x2);
	FOR(i, 0, n)
	{
		int j = -1;
		if (i <= mnX)
			j = 0;
		else if (i > mxX)
			j = 1;
		if (j == -1)
			continue;
		bool can2Up = (s[0][2 * i + j] != '1' && s[1][2 * i + j] != '2');
		res[0][2 * i + j] = can2Up ? '2' : '1';
		res[1][2 * i + j] = can2Up ? '1' : '2';
	}
	char digits[2];
	digits[0] = x2 < x1 ? '1' : '2';
	digits[1] = '1' ^ '2' ^ digits[0];
	FOR(i, mnX + 1, mxX + 1)
	{
		FOR(j, 0, 2)
		{
			if (s[0][2 * i + j] == '?' && s[1][2 * i + j] == '?')
				res[0][2 * i + j] = digits[j];
			else
			{
				FOR(k, 0, 2)
				{
					if (s[k][2 * i + j] != '?')
						res[k][2 * i + j] = s[k][2 * i + j];
				}
			}
		}
	}
	Big sum(0);
	string cur;
	FOR(i, 0, 2 * n)
	{
		if (res[0][i] == '0')
		{
			sum += cur;
			cur = "";
		}
		else
			cur += res[0][i];
	}
	sum += cur;
	return {sum, res};
}

void solve()
{
	cin >> n;
	FOR(i, 0, 2)
		cin >> s[i];
	int l[2] = {-1, -1}, r[2] = {n, n};
	FOR(i, 0, 2)
	{
		FOR(j, 0, 2 * n)
		{
			if (s[i][j] != '?')
			{
				int d = s[i][j] - '1';
				if (j % 2 == 0)
					updMax(l[d], j / 2);
				else
					updMin(r[d], j / 2);
			}
		}
	}
	bool impossible = l[0] >= r[0] || l[1] >= r[1];
	FOR(i, 0, 2)
		FOR(j, 0, 2 * n)
		{
			if (s[i][j] == '?')
				continue;
			FOR(di, -1, 2)
			{
				FOR(dj, -1, 2)
				{
					int ni = i + di, nj = j + dj;
					if (0 <= ni && ni < 2 && 0 <= nj && nj < 2 * n && !(ni == i && nj == j) && s[ni][nj] == s[i][j])
						impossible = true;
				}
			}
		}
	if (impossible)
	{
		cout << "impossible\n";
		return;
	}
	auto [sum1, res1] = f(l[0], r[1] - 1);
	auto [sum2, res2] = f(r[0] - 1, l[1]);
	if (sum1 < sum2)
	{
		sum1 = sum2;
		res1 = res2;
	}
	sum1.print();
	FOR(i, 0, 2)
		cout << res1[i] << "\n";
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

5
2
?1??
??1?
4
1???????
???2???2
5
??????????
??????????
6
1212????????
????????1212
7
?2?1?????1?2??
?????1???????2

output:

impossible
242
12101210
00020002
2121212121
2121212121
0000000000
12121212
121212120000
000000001212
21
12010202010201
00020101020102

result:

ok all is correct (5 test cases)

Test #2:

score: 0
Accepted
time: 10ms
memory: 7400kb

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #3:

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

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #4:

score: 0
Accepted
time: 10ms
memory: 7484kb

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #5:

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

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #6:

score: 0
Accepted
time: 10ms
memory: 5652kb

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #7:

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

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #8:

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

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #9:

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

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #10:

score: 0
Accepted
time: 61ms
memory: 3864kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212123333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #11:

score: 0
Accepted
time: 51ms
memory: 3780kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #12:

score: 0
Accepted
time: 22ms
memory: 3728kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #13:

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

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #14:

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

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #15:

score: 0
Accepted
time: 10ms
memory: 3972kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #16:

score: 0
Accepted
time: 61ms
memory: 3760kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #17:

score: 0
Accepted
time: 48ms
memory: 3812kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #18:

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

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #19:

score: 0
Accepted
time: 15ms
memory: 4056kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #20:

score: 0
Accepted
time: 12ms
memory: 3804kb

input:

200
5000
???2???????????????????????????????????????1???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #21:

score: 0
Accepted
time: 13ms
memory: 3748kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #22:

score: 0
Accepted
time: 56ms
memory: 3796kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #23:

score: 0
Accepted
time: 68ms
memory: 3780kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #24:

score: 0
Accepted
time: 20ms
memory: 4080kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #25:

score: 0
Accepted
time: 22ms
memory: 3752kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #26:

score: 0
Accepted
time: 12ms
memory: 4064kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #27:

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

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
121212121212121212121212121212121212121212121214242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424...

result:

ok all is correct (100 test cases)

Test #28:

score: 0
Accepted
time: 59ms
memory: 4024kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #29:

score: 0
Accepted
time: 67ms
memory: 3884kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #30:

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

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121213333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #31:

score: 0
Accepted
time: 18ms
memory: 3828kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #32:

score: 0
Accepted
time: 13ms
memory: 3816kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #33:

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

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #34:

score: 0
Accepted
time: 55ms
memory: 5244kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #35:

score: 0
Accepted
time: 63ms
memory: 6628kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #36:

score: 0
Accepted
time: 22ms
memory: 4980kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #37:

score: 0
Accepted
time: 16ms
memory: 6820kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #38:

score: 0
Accepted
time: 12ms
memory: 4400kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #39:

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

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible

result:

ok all is correct (10 test cases)

Test #40:

score: 0
Accepted
time: 68ms
memory: 5504kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #41:

score: 0
Accepted
time: 55ms
memory: 6936kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #42:

score: 0
Accepted
time: 23ms
memory: 5200kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #43:

score: 0
Accepted
time: 21ms
memory: 6632kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #44:

score: 0
Accepted
time: 13ms
memory: 4424kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #45:

score: 0
Accepted
time: 12ms
memory: 5696kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #46:

score: 0
Accepted
time: 66ms
memory: 5092kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #47:

score: 0
Accepted
time: 59ms
memory: 7224kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #48:

score: 0
Accepted
time: 21ms
memory: 5104kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #49:

score: 0
Accepted
time: 16ms
memory: 6892kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #50:

score: 0
Accepted
time: 16ms
memory: 5068kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #51:

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

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible

result:

ok all is correct (10 test cases)

Test #52:

score: 0
Accepted
time: 56ms
memory: 5008kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #53:

score: 0
Accepted
time: 59ms
memory: 7016kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #54:

score: 0
Accepted
time: 15ms
memory: 4636kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #55:

score: 0
Accepted
time: 22ms
memory: 6432kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #56:

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

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #57:

score: 0
Accepted
time: 13ms
memory: 4984kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #58:

score: 0
Accepted
time: 37ms
memory: 3604kb

input:

100000
1
??
2?
1
??
12
1
1?
2?
1
1?
??
1
1?
1?
1
1?
2?
1
?2
?1
1
?1
??
1
1?
??
1
??
?1
1
??
12
1
??
21
1
??
2?
1
1?
??
1
1?
??
1
?1
?2
1
2?
2?
1
??
?1
1
21
??
1
??
?1
1
2?
1?
1
?2
??
1
2?
2?
1
2?
2?
1
??
?1
1
1?
??
1
?2
?2
1
2?
?1
1
2?
1?
1
2?
1?
1
2?
1?
1
??
2?
1
??
12
1
1?
?2
1
??
?1
1
2?
?1
1
??
...

output:

1
01
20
0
00
12
1
10
20
12
12
00
impossible
1
10
20
2
02
01
21
21
00
12
12
00
2
20
01
0
00
12
0
00
21
1
01
20
12
12
00
12
12
00
1
01
02
impossible
2
20
01
21
21
00
2
20
01
2
20
10
12
12
00
impossible
impossible
2
20
01
12
12
00
impossible
2
20
01
2
20
10
2
20
10
2
20
10
1
01
20
0
00
12
1
10
02
2
20
...

result:

ok all is correct (100000 test cases)

Test #59:

score: 0
Accepted
time: 82ms
memory: 3584kb

input:

20000
50
?????????????????????????2??????????????????????????????????????????????????????????????????????????
?????2??????????????????????????????????????????????????????????????????????????????????????????????
50
?????????????????????????????2??????2?????????????????????????????????????????????????...

output:

1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212133333
1212101212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
0000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
imp...

result:

ok all is correct (20000 test cases)

Test #60:

score: 0
Accepted
time: 23ms
memory: 3532kb

input:

100000
1
2?
2?
1
?2
?2
1
21
??
1
21
21
1
2?
2?
1
21
21
1
?1
?1
1
?2
?2
1
?2
?2
1
2?
2?
1
?1
?1
1
12
12
1
1?
??
1
?1
?1
1
?1
?1
1
12
?2
1
?2
?2
1
1?
2?
1
1?
2?
1
12
12
1
?2
?2
1
2?
1?
1
12
?2
1
1?
2?
1
?2
?2
1
21
2?
1
?1
?1
1
2?
1?
1
2?
21
1
?2
?2
1
?2
?1
1
12
1?
1
?1
?1
1
12
12
1
12
12
1
1?
1?
1
?2
...

output:

impossible
impossible
21
21
00
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
12
12
00
impossible
impossible
impossible
impossible
1
10
20
1
10
20
impossible
impossible
2
20
10
impossible
1
10
20
impossible
impossible
impossible
2
20
10
impossible
...

result:

ok all is correct (100000 test cases)

Test #61:

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

input:

20000
50
???????????????????????1??????????????????????????????1?????????????????????????????????????????????
???????????????????????????????1??????????????2???????????????????????1???????????????1?????????????
50
?????????1?????????????????????????1???1??????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
21212121212121212196
2020202020202020202020102020202020202020201020202020202020201020202020202020102121212121212121212101
1010101010101010101010201010101010101010102010101010101010102010101010101010200000000000000000000020
impossible
21212121308...

result:

ok all is correct (20000 test cases)

Test #62:

score: 0
Accepted
time: 26ms
memory: 3496kb

input:

100000
1
21
21
1
12
12
1
2?
1?
1
1?
2?
1
21
21
1
12
12
1
12
1?
1
1?
2?
1
21
21
1
2?
21
1
?2
?2
1
?2
?2
1
12
12
1
12
12
1
21
21
1
2?
1?
1
21
21
1
2?
2?
1
2?
2?
1
2?
1?
1
1?
1?
1
?1
?2
1
21
21
1
?2
?2
1
?1
?1
1
12
12
1
21
21
1
2?
2?
1
21
21
1
21
21
1
2?
1?
1
1?
1?
1
1?
2?
1
21
?1
1
?2
?2
1
21
21
1
?1
...

output:

impossible
impossible
2
20
10
1
10
20
impossible
impossible
impossible
1
10
20
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
2
20
10
impossible
1
01
02
impossible
impossible
impossible
impossible
impossible
impossible
impossible...

result:

ok all is correct (100000 test cases)

Test #63:

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

input:

20000
50
???????1???????????????????2?2???????????????2?????????????1????????????????????????2???????????????
???????????????????????????2?????????????????????????1?????????????1??????2???????????????1?????????
50
?????????????????????????????????1?????????????????2???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
21212121212201
212121212121210101020...

result:

ok all is correct (20000 test cases)

Test #64:

score: 0
Accepted
time: 47ms
memory: 3844kb

input:

100000
1
?2
1?
1
2?
?1
1
?1
?1
1
2?
??
1
?2
?1
1
??
21
1
?1
2?
1
??
2?
1
2?
?1
1
?2
??
1
21
??
1
??
2?
1
??
21
1
??
21
1
1?
?2
1
21
??
1
2?
1?
1
21
??
1
?2
?1
1
2?
??
1
??
21
1
?1
?2
1
??
2?
1
2?
??
1
21
??
1
1?
??
1
?2
??
1
??
?2
1
?1
2?
1
?2
1?
1
?2
?2
1
?1
?1
1
??
21
1
2?
??
1
1?
2?
1
1?
1?
1
1?
...

output:

2
02
10
2
20
01
impossible
21
21
00
2
02
01
0
00
21
1
01
20
1
01
20
2
20
01
12
12
00
21
21
00
1
01
20
0
00
21
0
00
21
1
10
02
21
21
00
2
20
10
21
21
00
2
02
01
21
21
00
0
00
21
1
01
02
1
01
20
21
21
00
21
21
00
12
12
00
12
12
00
1
01
02
1
01
20
2
02
10
impossible
impossible
0
00
21
21
21
00
1
10
20
...

result:

ok all is correct (100000 test cases)

Test #65:

score: 0
Accepted
time: 73ms
memory: 3780kb

input:

20000
50
????????????????????????????????????????????????????????????????????????????????????????????????????
???????????1???????????????????????????????????????????????????????????????????????????2????????????
50
?????????????????2????????????????????????????????????????????????????????????????????...

output:

21212121212121212121212121212121212121212121212121212121212121233333333346
2121212121202121212121212121212121212121212121212121212121212121212121212121212121212101020202020202
0000000000010000000000000000000000000000000000000000000000000000000000000000000000000002010101010101
21212121212121212121212...

result:

ok all is correct (20000 test cases)

Test #66:

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

input:

100000
1
2?
2?
1
21
2?
1
2?
1?
1
12
??
1
1?
2?
1
2?
1?
1
?1
?1
1
?2
12
1
?2
?2
1
21
21
1
21
21
1
21
2?
1
?2
?1
1
2?
2?
1
12
12
1
2?
2?
1
2?
21
1
21
?1
1
?2
?2
1
2?
1?
1
?1
?1
1
21
21
1
?2
?2
1
12
12
1
1?
12
1
21
?1
1
?2
?1
1
?2
12
1
?1
21
1
21
?1
1
?1
?2
1
2?
2?
1
2?
2?
1
21
?1
1
?1
?1
1
21
21
1
21
...

output:

impossible
impossible
2
20
10
12
12
00
1
10
20
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
2
02
01
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
2
02
01
impossible
impossible
i...

result:

ok all is correct (100000 test cases)

Test #67:

score: 0
Accepted
time: 31ms
memory: 3552kb

input:

20000
50
?????????2????????????????????????????????????????????????????????2?????????1???????????????????????
??????????????????????????????1?2???????????????????????????????????????????????1???????????????????
50
?????????????????????????????????1????????????????????????????2???2???????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
233
2020202020202020202020102020202020202020202020202020202020201020202020202020202020202020202010210121
1010101010101010101010201010101010101010101010101010101010102010101010101010101010101010101020002000
impossible
212121...

result:

ok all is correct (20000 test cases)

Test #68:

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

input:

100000
1
?2
?2
1
2?
2?
1
12
12
1
21
21
1
21
21
1
?2
?1
1
?1
?2
1
1?
12
1
?1
?2
1
12
12
1
1?
2?
1
?1
?2
1
21
21
1
?1
?1
1
21
21
1
12
12
1
2?
1?
1
?2
?1
1
?1
?1
1
1?
12
1
?1
?2
1
12
12
1
?2
?2
1
1?
2?
1
?2
?2
1
21
21
1
21
21
1
12
12
1
21
21
1
21
21
1
?1
?2
1
21
21
1
21
21
1
21
21
1
1?
2?
1
21
21
1
21
...

output:

impossible
impossible
impossible
impossible
impossible
2
02
01
1
01
02
impossible
1
01
02
impossible
1
10
20
1
01
02
impossible
impossible
impossible
impossible
2
20
10
2
02
01
impossible
impossible
1
01
02
impossible
impossible
1
10
20
impossible
impossible
impossible
impossible
impossible
impossib...

result:

ok all is correct (100000 test cases)

Test #69:

score: 0
Accepted
time: 24ms
memory: 3776kb

input:

20000
50
????????????1??????????????????????????????????22?????????????1???????????????????????????????2?????
1???????1????????????????????2?2??????????????????????????1???????????????2???????????2?????????????
50
???????2?????????????????????2?????????????1????????????????????????????????????????1?...

output:

impossible
impossible
impossible
impossible
1226363636421
2020202010202010202020102020202020201020102020202020202020201020212121212101212121212121012121212121
1010101020101020101010201010101010102010201010101010101010102010000000000020000000000000200000000000
impossible
12121212121213333333333333545...

result:

ok all is correct (20000 test cases)

Test #70:

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

input:

100000
1
?1
?1
1
1?
1?
1
2?
1?
1
??
?2
1
?1
?2
1
?1
??
1
?2
??
1
1?
??
1
2?
2?
1
1?
??
1
2?
??
1
?2
?1
1
2?
?1
1
2?
2?
1
??
2?
1
2?
2?
1
?2
?2
1
2?
??
1
??
2?
1
?1
2?
1
2?
?1
1
??
?1
1
2?
?1
1
??
21
1
1?
1?
1
2?
2?
1
1?
??
1
2?
2?
1
??
1?
1
?2
??
1
2?
2?
1
1?
1?
1
?1
?1
1
?2
?2
1
??
?2
1
?2
?2
1
2?
...

output:

impossible
impossible
2
20
10
1
01
02
1
01
02
21
21
00
12
12
00
12
12
00
impossible
12
12
00
21
21
00
2
02
01
2
20
01
impossible
1
01
20
impossible
impossible
21
21
00
1
01
20
1
01
20
2
20
01
2
20
01
2
20
01
0
00
21
impossible
impossible
12
12
00
impossible
2
20
10
12
12
00
impossible
impossible
imp...

result:

ok all is correct (100000 test cases)

Test #71:

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

input:

20000
50
??????????????????????????????????????????????????????????????????????1?????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????2???
50
??????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212313
2020202020202020202020202020202020202020202020202020202020202020202020102121212121212121212121210121
1010101010101010101010101010101010101010101010101010101010101010101010200000000000000000000000002000
12121212121212121212121213345454545454545454545454
1212121212121212121212...

result:

ok all is correct (20000 test cases)

Test #72:

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

input:

100000
1
?1
?1
1
2?
21
1
1?
2?
1
?1
?2
1
?1
?2
1
21
21
1
21
?1
1
1?
1?
1
12
??
1
2?
21
1
21
2?
1
1?
1?
1
1?
2?
1
?2
12
1
?2
?2
1
1?
2?
1
2?
2?
1
12
12
1
?1
?2
1
1?
12
1
?2
?1
1
?1
?2
1
1?
2?
1
?2
?1
1
?1
?1
1
1?
1?
1
1?
?2
1
1?
1?
1
1?
2?
1
21
21
1
?2
?2
1
21
21
1
?2
?1
1
21
2?
1
2?
1?
1
?2
?2
1
1?
...

output:

impossible
impossible
1
10
20
1
01
02
1
01
02
impossible
impossible
impossible
12
12
00
impossible
impossible
impossible
1
10
20
impossible
impossible
1
10
20
impossible
impossible
1
01
02
impossible
2
02
01
1
01
02
1
10
20
2
02
01
impossible
impossible
1
10
02
impossible
1
10
20
impossible
impossib...

result:

ok all is correct (100000 test cases)

Test #73:

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

input:

20000
50
?????????2???2???????2??????????????????????????????????????????????2???????2???????????????????????
????????????????????????????????????????????????????????????????????????????????1???????????????????
50
?????????2?????????????????1??????????????????????????????????????????????????????????...

output:

impossible
impossible
214242424242424242500
2121212121212121212021212121212121212121202102020201020202020202020202020202020202020202020202020202
0000000000000000000100000000000000000000010001010102010101010101010101010101010101010101010101010101
impossible
2121212121295
21212121212120010202020202020...

result:

ok all is correct (20000 test cases)

Test #74:

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

input:

100000
1
12
?2
1
?1
?1
1
12
12
1
?2
?2
1
21
21
1
2?
1?
1
21
21
1
21
21
1
21
21
1
2?
1?
1
?2
?1
1
21
21
1
21
21
1
21
21
1
2?
1?
1
?1
?2
1
21
21
1
12
12
1
21
21
1
2?
2?
1
21
21
1
12
12
1
?1
?1
1
2?
1?
1
12
12
1
2?
2?
1
21
21
1
12
1?
1
12
12
1
?2
12
1
12
12
1
2?
2?
1
21
21
1
?2
?2
1
12
12
1
?1
?1
1
?2
...

output:

impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
2
20
10
2
02
01
impossible
impossible
impossible
2
20
10
1
01
02
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible...

result:

ok all is correct (100000 test cases)

Test #75:

score: 0
Accepted
time: 20ms
memory: 3808kb

input:

20000
50
???1???1????????????????2?????????????????????2?????????????????2?????????????????????????????1?????
????????????????2?????????????????????????????????2????????????????1????2???????????????????????????
50
???????????????????????1????????????????2???????????????????????????????????????1?????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2121212121212142426363636363670
2020202020202020101020202020202020200212121212121202121212121212121212121212121212021212121212121212
10101010101010102020101010101010101010000000000000100000000000000000...

result:

ok all is correct (20000 test cases)

Test #76:

score: 0
Accepted
time: 45ms
memory: 3612kb

input:

100000
1
2?
2?
1
2?
??
1
??
?2
1
2?
?1
1
2?
1?
1
??
2?
1
21
??
1
?1
?2
1
2?
2?
1
2?
?1
1
1?
1?
1
1?
1?
1
??
12
1
1?
2?
1
2?
1?
1
?2
?2
1
1?
?2
1
1?
?2
1
?1
??
1
2?
2?
1
1?
?2
1
1?
?2
1
2?
??
1
2?
1?
1
12
??
1
?2
?2
1
?2
1?
1
??
1?
1
12
??
1
1?
1?
1
??
21
1
?1
?2
1
2?
1?
1
??
1?
1
??
?1
1
1?
?2
1
?1
...

output:

impossible
21
21
00
1
01
02
2
20
01
2
20
10
1
01
20
21
21
00
1
01
02
impossible
2
20
01
impossible
impossible
0
00
12
1
10
20
2
20
10
impossible
1
10
02
1
10
02
21
21
00
impossible
1
10
02
1
10
02
21
21
00
2
20
10
12
12
00
impossible
2
02
10
2
20
10
12
12
00
impossible
0
00
21
1
01
02
2
20
10
2
20
1...

result:

ok all is correct (100000 test cases)

Test #77:

score: 0
Accepted
time: 81ms
memory: 3852kb

input:

20000
50
????????????????????????????????????????????????????????????1???????????????????1???????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????
50
??????????????????????????????????????????????????????????????????????????????????????...

output:

1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok all is correct (20000 test cases)

Test #78:

score: 0
Accepted
time: 27ms
memory: 3612kb

input:

100000
1
?1
?2
1
21
21
1
?2
?2
1
2?
2?
1
1?
2?
1
21
?1
1
?1
?1
1
21
2?
1
12
12
1
1?
2?
1
?2
?2
1
21
21
1
?2
?1
1
1?
1?
1
?2
1?
1
?2
12
1
12
1?
1
1?
1?
1
2?
1?
1
12
1?
1
12
12
1
2?
2?
1
21
?1
1
21
?1
1
1?
1?
1
?2
12
1
2?
1?
1
?1
?1
1
1?
2?
1
?1
21
1
?1
?2
1
?2
?1
1
2?
1?
1
12
12
1
2?
1?
1
12
1?
1
?2
...

output:

1
01
02
impossible
impossible
impossible
1
10
20
impossible
impossible
impossible
impossible
1
10
20
impossible
impossible
2
02
01
impossible
2
02
10
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
1
10
20
impos...

result:

ok all is correct (100000 test cases)

Test #79:

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

input:

20000
50
???1?????2???????????????????????????????????????????2????????????????????????????????????????2?????
?????????1????????????????????????????????????????????????????????????2?????????????????????????????
50
???????????????????1??????????????????????????????????????????????????????????????????...

output:

impossible
impossible
1212121212121224263659699092120
2121212121202121212121212101212021212120212121212101212121212121212101212121212121212121212121212121
0000000000010000000000000020000100000001000000000020000000000000000020000000000000000000000000000000
impossible
1214242424242424242424293
2020202...

result:

ok all is correct (20000 test cases)

Test #80:

score: 0
Accepted
time: 26ms
memory: 3552kb

input:

100000
1
2?
2?
1
21
21
1
2?
2?
1
2?
1?
1
21
21
1
1?
1?
1
21
21
1
?1
?1
1
21
21
1
?1
?2
1
2?
1?
1
2?
1?
1
?1
?1
1
21
21
1
2?
1?
1
1?
1?
1
2?
1?
1
21
21
1
21
?1
1
12
12
1
12
12
1
12
12
1
21
21
1
1?
1?
1
12
12
1
2?
1?
1
2?
2?
1
21
21
1
2?
2?
1
?1
?2
1
21
21
1
1?
12
1
2?
2?
1
?2
?2
1
21
21
1
12
12
1
21
...

output:

impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
1
01
02
2
20
10
2
20
10
impossible
impossible
2
20
10
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
1
...

result:

ok all is correct (100000 test cases)

Test #81:

score: 0
Accepted
time: 24ms
memory: 3808kb

input:

20000
50
?1???????1????????????????????2?????????????????????????????????????2???????????????????????????????
?2?????????????1???1????????????????????????????????????????????????1???2?????????????1???????1?????
50
???????????????????????2??????????????????2???????2??????????????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
2121212242424365758909112...

result:

ok all is correct (20000 test cases)

Extra Test:

score: 0
Extra Test Passed