QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#465449#8825. Puzzle: Summon中国入民小学附属信息I队 (Zicheng Wang, Shubang Liu, Minkai Shao)AC ✓71ms29132kbC++176.3kb2024-07-06 22:03:092024-07-06 22:03:09

Judging History

This is the latest submission verdict.

  • [2024-07-06 22:03:09]
  • Judged
  • Verdict: AC
  • Time: 71ms
  • Memory: 29132kb
  • [2024-07-06 22:03:09]
  • Submitted

answer

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

typedef long long ll;
const int maxn = 2e6 + 5;

int cnt[250];
char s[maxn], t[maxn], ss[maxn], tt[maxn];
int op[maxn], nl[maxn], nr[maxn];
int pre[maxn], suf[maxn];

int c[maxn << 1], ans[maxn << 1], ansl, clen, aL, aR, aot;

void clear()
{
    for (int i = clen; ~i; i--) c[i] = 0;
    clen = 0;
}

void add(int x, int y)
{
    clen = max(clen, y - x);
    for (int i = y; i >= x; i--) c[y - i] += s[i] - '0';
    for (int i = 0; i <= clen; i++)
        if (c[i] >= 10)
        {
            if (i == clen) clen++;
            c[i + 1] += c[i] / 10, c[i] %= 10;
        }
}

void upd(int t)
{
    c[0] += t;
    int nw = 0;
    while (c[nw] >= 10)
    {
        if (nw == clen) clen++;
        c[nw + 1] += c[nw] / 10; c[nw] %= 10;
        nw++;
    }
}

void compare(int L, int R, int ot)
{
    if (clen < ansl) return;
    if (clen > ansl)
    {
        ansl = clen;
        for (int i = ansl; ~i; i--) ans[i] = c[i];
        aL = L, aR = R, aot = ot;
        return;
    }

    for (int i = ansl; ~i; i--)
    {
        if (c[i] > ans[i])
        {
            for (int j = i; ~j; j--) ans[j] = c[j];
            aL = L, aR = R, aot = ot;
            return;
        }
        else if (c[i] < ans[i]) break;
    }
    aL = L, aR = R, aot = ot;
}

void work()
{
    int n; cin >> n >> s + 1 >> t + 1;
    for (int i = 1; i <= 2 * n; i++) ss[i] = s[i], tt[i] = t[i];
    for (int i = 1; i <= n; i++) op[i] = -1, nl[i] = nr[i] = 0;
    int mx1 = 0, mn2 = n + 1;
    for (int i = 1; i <= 2 * n; i += 2)
    {
        int x = i / 2 + 1;
        cnt['1'] = cnt['2'] = cnt['?'] = 0;
        cnt[s[i]]++, cnt[t[i]]++, cnt[s[i + 1]]++, cnt[t[i + 1]]++;
        if (cnt['1'] > 1 || cnt['2'] > 1)
        {
            cout << "impossible\n";
            return;
        }
        if (s[i + 1] == '?' && t[i + 1] == '?' && cnt['1'] && cnt['2']) mx1 = max(mx1, x), nl[x] = 1;
        else if (s[i] == '?' && t[i] == '?' && cnt['1'] && cnt['2']) mn2 = min(mn2, x), nr[x] = 1;

        if (s[i + 1] == '?' && t[i + 1] == '?') nl[x] = 1;
        if (s[i] == '?' && t[i] == '?') nr[x] = 1;

        if (!cnt['1'] && !cnt['2']) op[x] = -1;
        if (cnt['1'])
        {
            if (s[i] == '1' || t[i] == '1') op[x] = 1;
            else op[x] = 0;
        }
        if (cnt['2'])
        {
            if (s[i] == '2' || t[i] == '2') op[x] = 0;
            else op[x] = 1;
        }
    }

    for (int i = 1; i < 2 * n; i++)
        if (s[i] != '?' && s[i] == s[i + 1] || t[i] != '?' && t[i] == t[i + 1] || s[i] != '?' && s[i] == t[i + 1] || t[i] != '?' && t[i] == s[i + 1])
        {
            cout << "impossible\n";
            return;
        }
    
    for (int i = ansl; ~i; i--) ans[i] = 0;
    ansl = 0, aL = aR = -1;

    int L = 0, R = n + 1;
    while (nl[L + 1]) L++;
    while (nr[R - 1]) R--;
    suf[n + 1] = 0;
    for (int i = 1; i <= L; i++) pre[i] = pre[i - 1] + (s[2 * i - 1] != '?' ? s[2 * i - 1] - '0' : (t[2 * i - 1] != '?' ? '3' - t[2 * i - 1] : 2));
    for (int i = n; i >= R; i--) suf[i] = suf[i + 1] + (s[2 * i] != '?' ? s[2 * i] - '0' : (t[2 * i] != '?' ? '3' - t[2 * i] : 2));

    if (L >= R - 1)
    {
        clear();
        upd(pre[L] + suf[L + 1]);
        compare(L + 1, L, 0);
    }


    int l = mx1 + 1, lstl = mx1 + 1;
    while (l < mn2)
    {
        int r = l, p = op[l];
        while (r + 1 < mn2)
        {
            if (p == -1)
            {
                p = op[r + 1];
                r++;
                continue;
            }
            if (op[r + 1] == -1) r++;
            else if (p == op[r + 1]) r++;
            else break;
        }

        if (l > L + 1 || r < R - 1 || l <= mx1 || r >= mn2)
        {
            lstl = r + 1;
            while (op[lstl - 1] == -1) lstl--;
            l = r + 1;
            continue;
        }

        for (int i = lstl; i < l; i++) s[2 * i - 1] = s[2 * i] = t[2 * i - 1] = t[2 * i] = '?';
        int opt = p; l = lstl;
        for (int i = l; i <= r; i++)
            if (opt == -1) s[2 * i - 1] = '2', s[2 * i] = '1';
            else
            {
                if (s[2 * i - 1] == '?' && t[2 * i - 1] == '?')
                {
                    if (opt == 0) s[2 * i - 1] = '2';
                    else s[2 * i - 1] = '1';
                }
                if (s[2 * i] == '?' && t[2 * i] == '?')
                {
                    if (opt == 0) s[2 * i] = '1';
                    else s[2 * i] = '2';
                }
            }
        
        int x = 2 * l - 1;
        clear();
        while (x <= 2 * r)
        {
            if (s[x] == '?')
            {
                x++;
                continue;
            }
            int y = x;
            while (y < 2 * r && s[y + 1] != '?') y++;
            add(x, y);
            x = y + 1;
        }
        upd(pre[l - 1] + suf[r + 1]);
        compare(l, r, opt);
        lstl = r + 1;
        while (op[lstl - 1] == -1) lstl--;
        l = r + 1;
    }

    if (aL == -1 && aR == -1)
    {
        cout << "impossible\n";
        return;
    }

    for (int i = ansl; ~i; i--) cout << ans[i]; cout << "\n";
    for (int i = 1; i <= 2 * n; i++) s[i] = ss[i], t[i] = tt[i];
    
    for (int i = 1; i < aL; i++)
    {
        int x = pre[i] - pre[i - 1];
        s[2 * i - 1] = '0' + x, t[2 * i - 1] = '3' - x;
    }

    for (int i = aR + 1; i <= n; i++)
    {
        int x = suf[i] - suf[i + 1];
        s[2 * i] = '0' + x, t[2 * i] = '3' - x;
    }

    for (int i = aL; i <= aR; i++)
        if (aot == -1) s[2 * i - 1] = '2', s[2 * i] = '1';
        else
        {
            if (s[2 * i - 1] == '?' && t[2 * i - 1] == '?')
            {
                if (aot == 0) s[2 * i - 1] = '2';
                else s[2 * i - 1] = '1';
            }
            if (s[2 * i] == '?' && t[2 * i] == '?')
            {
                if (aot == 0) s[2 * i] = '1';
                else s[2 * i] = '2';
            }
        }
    
    for (int i = 1; i <= 2 * n; i++) cout << (s[i] == '?' ? '0' : s[i]); cout << "\n";
    for (int i = 1; i <= 2 * n; i++) cout << (t[i] == '?' ? '0' : t[i]); cout << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int T;
    cin >> T;
    while (T--) work();
    return 0;
}

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

詳細信息

Test #1:

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

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: 14ms
memory: 27376kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #3:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #4:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #5:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #6:

score: 0
Accepted
time: 9ms
memory: 24756kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #7:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #8:

score: 0
Accepted
time: 9ms
memory: 24812kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #9:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #10:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212123333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #11:

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

input:

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

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #12:

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

input:

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

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #13:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #14:

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

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: 16ms
memory: 22140kb

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: 55ms
memory: 22244kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #17:

score: 0
Accepted
time: 62ms
memory: 24216kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #18:

score: 0
Accepted
time: 19ms
memory: 22224kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #19:

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

input:

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

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #20:

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

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: 7ms
memory: 20156kb

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: 57ms
memory: 22188kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #23:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #24:

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

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: 25ms
memory: 22180kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #26:

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

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: 15ms
memory: 22220kb

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: 57ms
memory: 22192kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #29:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #30:

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

input:

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

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121213333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #31:

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

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: 18ms
memory: 20112kb

input:

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

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #33:

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

input:

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

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #34:

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #35:

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #36:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #37:

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

input:

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

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #38:

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

input:

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

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #39:

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

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: 66ms
memory: 24372kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #41:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #42:

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #43:

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

input:

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

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #44:

score: 0
Accepted
time: 17ms
memory: 24480kb

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: 19ms
memory: 22324kb

input:

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

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #46:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #47:

score: 0
Accepted
time: 50ms
memory: 23284kb

input:

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

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #48:

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

input:

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

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #49:

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

input:

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

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #50:

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

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: 6ms
memory: 22256kb

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: 60ms
memory: 26788kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #53:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #54:

score: 0
Accepted
time: 19ms
memory: 24472kb

input:

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

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #55:

score: 0
Accepted
time: 29ms
memory: 29132kb

input:

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

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #56:

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

input:

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

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #57:

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

input:

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

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #58:

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

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: 68ms
memory: 22176kb

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: 16ms
memory: 22180kb

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: 32ms
memory: 22064kb

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: 15ms
memory: 22112kb

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: 22056kb

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: 24ms
memory: 22116kb

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
10
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: 67ms
memory: 22120kb

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: 12ms
memory: 22056kb

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: 32ms
memory: 22064kb

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: 18ms
memory: 20084kb

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: 19ms
memory: 20088kb

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: 24ms
memory: 22184kb

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
10
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
02
10
12
12
00
impossible
impossible
imp...

result:

ok all is correct (100000 test cases)

Test #71:

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

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: 20ms
memory: 20068kb

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: 31ms
memory: 22064kb

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: 11ms
memory: 22132kb

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: 17ms
memory: 22128kb

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: 28ms
memory: 22056kb

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
10
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
02
10
12
12
00
impossible
0
00
21
1
01
02
2
20
10
2
02
1...

result:

ok all is correct (100000 test cases)

Test #77:

score: 0
Accepted
time: 71ms
memory: 22172kb

input:

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

output:

1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok all is correct (20000 test cases)

Test #78:

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

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: 22184kb

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: 15ms
memory: 20012kb

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: 20ms
memory: 22052kb

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