QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#597609#8825. Puzzle: Summon口嗨战神 (Binyang Jiang, Dayu Wang, Hejun Dong)#AC ✓48ms7476kbC++206.1kb2024-09-28 18:09:512024-09-28 18:09:52

Judging History

This is the latest submission verdict.

  • [2024-09-28 18:09:52]
  • Judged
  • Verdict: AC
  • Time: 48ms
  • Memory: 7476kb
  • [2024-09-28 18:09:51]
  • Submitted

answer

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

using ll = long long;

string operator+(string a, string b) {
    if(a.size() < b.size()) swap(a, b);
    if(b.size() == a.size()) a.push_back('0');
    int flg = 0;
    // cerr << a << "|" << b << '\n';
    for(int i = 0; i < b.size(); i++) {
        int now = a[i] - '0' + b[i] - '0' + flg;
        a[i] = now % 10 + '0', flg = now / 10;
    }
    for(int i = b.size(); i < a.size() && flg; i++) {
        int now = a[i] - '0' + flg;
        a[i] = now % 10 + '0', flg = now / 10;
    }
    while(a.size() && a.back() == '0') a.pop_back();
    return a;
}
string operator+(string a, int b) {
    string c = to_string(b);
    reverse(c.begin(), c.end());
    return a + c;
}
bool operator<(string a, string b) {
    if(a.size() != b.size()) return a.size() < b.size();
    for(int i = (int)a.size() - 1; i >= 0; i--) {
        if(a[i] != b[i]) return a[i] < b[i];
    }
    return 1;
}

void solve() {
    int n;
    string s[2];
    cin >> n >> s[0] >> s[1];
    vector<array<int, 4>> ve(n + 1);
    for(int i = 1; i <= n; i++) {
        auto calc = [&](char ch) {
            if(ch == '?') return 0;
            else return ch - '0';
        };
        ve[i] = {
            calc(s[0][2 * i - 2]),
            calc(s[1][2 * i - 2]),
            calc(s[0][2 * i - 1]),
            calc(s[1][2 * i - 1]),
        };
        int cnt[3] = {0, 0};
        for(auto j : ve[i]) {
            cnt[j]++;
        }
        if(cnt[1] > 1 || cnt[2] > 1) {
            cout << "impossible\n";
            return;
        }
    }
    // for(int i = 1; i <= n; i++) {
    //     auto [a, b, c, d] = ve[i];
    //     // cerr << a << ' ' << b << ' ' << c << ' ' << d << '\n';
    // }
    int l = 0, r = n + 1;
    for(int i = 1; i <= n; i++) {
        auto [a, b, c, d] = ve[i];
        if(a && b) l = i;
        if(c && d && r == n + 1) r = i;
    }
    if(l > r) {
        cout << "impossible\n";
        return;
    }
    vector<int> pre(n + 1), suf(n + 2);
    for(int i = 1; i <= n; i++) {
        auto [a, b, c, d] = ve[i];
        if(c || d) pre[i] = -1e9;
        else if(b == 2 || a == 1) pre[i] = pre[i - 1] + 1;
        else pre[i] = pre[i - 1] + 2;
    }
    for(int i = n; i; i--) {
        auto [a, b, c, d] = ve[i];
        if(a || b) suf[i] = -1e9;
        else if(d == 2 || c == 1) suf[i] = suf[i + 1] + 1;
        else suf[i] = suf[i + 1] + 2;
    }
    vector<int> ty(n + 1);
    for(int i = l + 1; i < r; i++) {
        auto [a, b, c, d] = ve[i];
        int L = max(a, b), R = max(c, d);
        if(!(L == 1 || R == 2)) ty[i] |= 2; // 1 -> 2 1
        if(!(L == 2 || R == 1)) ty[i] |= 1; // 2 -> 1 2
    }
    auto neg = [&](int x) {
        return x == 1 ? 2 : 1;
    };
    auto add = [&](int len, int beg, string &now) {
        string ad;
        for(int i = 0, t = beg; i < len; i++) {
            ad += t + '0';
            t = neg(t);
        }
        reverse(ad.begin(), ad.end());
        now = now + ad;
    };
    string ans;
    int L = -1, R = -1, Ty = -1, ff = 0;
    for(int i = l; i < r; i++) {
        // cerr << pre[i] << ' ' << suf[i + 1] << '\n';
        if(pre[i] >= 0 && suf[i + 1] >= 0) {
            string now = to_string(pre[i] + suf[i + 1]);
            reverse(now.begin(), now.end());
            // string now;
            // now = now + pre[i] + suf[i + 1];
            // cerr << now << '\n';
            if(ans < now) {
                ff = 1;
                ans = now, L = i + 1, R = i;
            }
        }
    }
    for(int fuck = 1; fuck <= 2; fuck++) {
        for(int i = l + 1, j; i < r; i = j + 1) {
            j = i;
            if(!(ty[i] & fuck)) continue;
            while(j + 1 < r && (ty[j + 1] & fuck)) j++;
            if(pre[i - 1] < 0 || suf[j + 1] < 0) continue;
            string now;
            int len = 0, beg = fuck;
            for(int k = i; k <= j; k++) {
                auto [a, b, c, d] = ve[k];
                if(b == fuck) {
                    add(len, beg, now), len = 0, beg = neg(fuck);
                } else len++;
                if(d == neg(fuck)) {
                    add(len, beg, now), len = 0, beg = fuck;
                } else len++;
            }
            add(len, beg, now);
            now = now + pre[i - 1] + suf[j + 1];
            if(ans < now) {
                ans = now, L = i, R = j, Ty = fuck;
                ff = 1;
            }
        }
    }
    if(ff && ans.empty()) ans = "0";
    if(ans.empty()) {
        cout << "impossible\n";
        return;
    }
    reverse(ans.begin(), ans.end());
    // cerr << L << ' ' << R << ' ' << Ty << '\n';
    cout << ans << '\n';
    string tab[2];
    tab[0] = tab[1] = string(2 * n, '0');
    for(int i = 1; i < L; i++) {
        auto [a, b, c, d] = ve[i];
        if(b != 2 && a != 1) {
            tab[0][2 * i - 2] = '2';
            tab[1][2 * i - 2] = '1';
        } else {
            tab[0][2 * i - 2] = '1';
            tab[1][2 * i - 2] = '2';
        }
    }
    for(int i = L; i <= R; i++) {
        auto [a, b, c, d] = ve[i];
        if(b != Ty) {
            tab[0][2 * i - 2] = Ty + '0';
        } else {
            tab[1][2 * i - 2] = Ty + '0';
        }
        if(d != neg(Ty)) {
            tab[0][2 * i - 1] = neg(Ty) + '0';
        } else {
            tab[1][2 * i - 1] = neg(Ty) + '0';
        }
    }
    for(int i = R + 1; i <= n; i++) {
        auto [a, b, c, d] = ve[i];
        if(d != 2 && c != 1) {
            tab[0][2 * i - 1] = '2';
            tab[1][2 * i - 1] = '1';
        } else {
            tab[0][2 * i - 1] = '1';
            tab[1][2 * i - 1] = '2';
        }
    }
    cout << tab[0] << '\n' << tab[1] << '\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}
/*
1
4
1???????
???2???2

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

1
2
1??1
2??2

*/

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

詳細信息

Test #1:

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

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #3:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #4:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #5:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #6:

score: 0
Accepted
time: 8ms
memory: 5620kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #7:

score: 0
Accepted
time: 8ms
memory: 5812kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #8:

score: 0
Accepted
time: 8ms
memory: 5584kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #9:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #10:

score: 0
Accepted
time: 25ms
memory: 3920kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212123333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #11:

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

input:

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

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #12:

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

input:

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

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #13:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #14:

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

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

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #17:

score: 0
Accepted
time: 28ms
memory: 3824kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #18:

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #19:

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

input:

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

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #20:

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

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

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #23:

score: 0
Accepted
time: 28ms
memory: 4140kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #24:

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

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #26:

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

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

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #29:

score: 0
Accepted
time: 25ms
memory: 3824kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #30:

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

input:

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

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121213333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #31:

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

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

input:

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

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #33:

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

input:

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

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #34:

score: 0
Accepted
time: 28ms
memory: 5468kb

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #35:

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #36:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #37:

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

input:

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

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #38:

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

input:

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

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #39:

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

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #41:

score: 0
Accepted
time: 32ms
memory: 7228kb

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #42:

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #43:

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

input:

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

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #44:

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

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

input:

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

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #46:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #47:

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

input:

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

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #48:

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

input:

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

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #49:

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

input:

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

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #50:

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

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

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

input:

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

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #53:

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

input:

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

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #54:

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

input:

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

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #55:

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

input:

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

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #56:

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

input:

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

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #57:

score: 0
Accepted
time: 25ms
memory: 6888kb

input:

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

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #58:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

input:

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

output:

1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok all is correct (20000 test cases)

Test #78:

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

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

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

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

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