QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#72621#5167. 魔术师Chinese_zjc_100 ✓155ms9476kbC++146.9kb2023-01-17 09:08:302023-01-17 09:08:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-17 09:08:55]
  • 评测
  • 测评结果:100
  • 用时:155ms
  • 内存:9476kb
  • [2023-01-17 09:08:30]
  • 提交

answer

// This Code was made by Chinese_zjc_.
#include <bits/stdc++.h>
unsigned long long seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 Rand(seed);
int T, n, m;
std::vector<int> a, ans;
bool any(int) { return true; }
void reverse(int pos) { ans.push_back(pos), std::reverse(a.begin() + pos, a.begin() + pos + m); }
void lshift(int pos) { reverse(pos + 1), reverse(pos); }
void rshift(int pos) { reverse(pos), reverse(pos + 1); }
bool check()
{
    for (int i = 0; i != n; ++i)
        if (a[i] != i)
            return false;
    return true;
}
void print()
{
    std::cout << ans.size() << std::endl;
    for (auto i : ans)
        std::cout << i << '\n';
    exit(0);
}
void NO() { std::cout << -1 << std::endl, exit(0); }
void submit() { check() ? print() : NO(); }
bool calc(bool check(int))
{
    bool res = false;
    for (int i = 0; i != n; ++i)
        if (check(i))
            for (int j = i; ++j != n;)
                if (check(j))
                    res ^= a[i] > a[j];
    return res;
}
void shifto(int pos, int val)
{
    if (val < 0)
        val += m + 1;
    int A = val, B = m + 1 - val;
    if (A & 1)
        A = INT_MAX;
    if (B & 1)
        B = INT_MAX;
    if (A == INT_MAX && B == INT_MAX)
        NO();
    if (A < B)
        for (int i = 0; i != A >> 1; ++i)
            rshift(pos);
    else
        for (int i = 0; i != B >> 1; ++i)
            lshift(pos);
}
void down(std::size_t lim)
{
    while (a.size() > lim)
    {
        int pos = std::find(a.begin(), a.end(), a.size() - 1) - a.begin();
        while (pos + m <= int(a.size()))
            reverse(pos), pos += m - 1;
        if (((a.size() - 1) ^ pos) & 1)
            reverse(a.size() - m), pos = a.size() * 2 - m - 1 - pos;
        if (int(a.size() + pos) / 2 >= m)
        {
            reverse((a.size() + pos + 1) / 2 - m);
            reverse(a.size() - m);
        }
        shifto(a.size() - m - 1, std::prev(a.end(), 1) - std::find(a.begin(), a.end(), a.size() - 1));
        a.pop_back();
    }
    n = a.size();
}
bool solve_0(int pos, bool check())
{
    if (check())
        return true;
    reverse(pos);
    if (check())
        return true;
    return false;
}
bool solve_1(int A, int B, bool check())
{
    for (int i = 0; i != n; ++i)
    {
        if (check())
            return true;
        reverse(A);
        if (check())
            return true;
        reverse(B);
    }
    return false;
}
void solve_2(void shifto(int, int))
{
    if (a.front() == 2)
        shifto(0, 1);
    shifto(1, std::prev(a.end(), 1) - std::find(a.begin(), a.end(), 2));
    if (((n - 3) ^ calc(any)) & 1)
        shifto(0, 1);
    for (int i = 3; i != n; ++i)
    {
        int pos = std::find(a.begin(), a.end(), i) - a.begin();
        if (pos == 0)
        {
            shifto(1, std::prev(a.end(), 2) - std::find(a.begin(), a.end(), i - 1));
            shifto(0, std::prev(a.end(), 2 + (i != n - 1 && ~m & 1)) - std::find(a.begin(), a.end(), i));
            shifto(1, std::prev(a.end(), 1) - std::find(a.begin(), a.end(), i));
        }
        else
        {
            shifto(1, std::prev(a.end(), 1) - std::find(a.begin(), a.end(), i));
            shifto(0, std::prev(a.end(), 2) - std::find(a.begin(), a.end(), i - 1));
        }
    }
    // for (int i = 0; i != n; ++i)
    //     std::cout << a[i] << " \n"[i + 1 == n];
}
namespace odd
{
    bool odd(int pos) { return pos & 1; }
    bool even(int pos) { return !odd(pos); }
    void shifto(int pos, int val)
    {
        static const int len = (m + 1) >> 1;
        if (val < 0)
            val += len;
        int A = val, B = len - val;
        if (A < B)
            for (int i = 0; i != A; ++i)
                ans.push_back(pos << 1), ans.push_back(pos << 1 | 1);
        else
            for (int i = 0; i != B; ++i)
                ans.push_back(pos << 1 | 1), ans.push_back(pos << 1);
        std::rotate(a.begin() + pos, a.begin() + pos + len - val, a.begin() + pos + len);
    }
    bool check_odd()
    {
        for (int i = 0; i != n; ++i)
            if (odd(i) && a[i] != i)
                return false;
        return true;
    }
    bool check_even()
    {
        for (int i = 0; i != n; ++i)
            if (even(i) && a[i] != i)
                return false;
        return true;
    }
    void bind()
    {
        for (int i = 0; i != n >> 1; ++i)
        {
            if (a[m + 1] == a[1] - 1)
                lshift(1);
            else
            {
                int v = a[1];
                ::shifto(0, a.begin() - std::find(a.begin(), a.end(), v - 1));
                ::shifto(1, a.begin() + 1 - std::find(a.begin(), a.end(), v));
                lshift(0);
            }
            // for (int i = 0; i != n; ++i)
            //     std::cout << a[i] << " \n"[i + 1 == n];
        }
    }
    void solve_2()
    {
        int pos = std::find(a.begin(), a.end(), 1) - a.begin();
        if ((pos + 2 == n ? a[1] : a[pos + 2]) != 3)
            reverse(1);
        bind();
        ::shifto(0, a.begin() - std::find(a.begin(), a.end(), 0));
    }
    void solve_3()
    {
        bool A = (m + 1) >> 2 & 1, B = (m - 1) >> 2 & 1;
        bool Odd = calc(odd), Even = calc(even);
        bool flag = false;
        for (int i = 0; i != 2 && !flag; ++i)
            for (int j = 0; j != 2 && !flag; ++j)
                if ((Odd ^ (i ? A : 0) ^ (j ? B : 0)) == 0 &&
                    (Even ^ (i ? B : 0) ^ (j ? A : 0)) == 0)
                {
                    if (i)
                        reverse(0);
                    if (j)
                        reverse(1);
                    flag = true;
                }
        if (!flag)
            return;
        bind();
        for (int i = n; i--;)
            if (odd(i))
                a.erase(a.begin() + i);
            else
                a[i] >>= 1;
        n = a.size();
        ::solve_2(shifto);
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin >> T >> n >> m;
    a.resize(n);
    for (int i = 0; i != n; ++i)
        std::cin >> a[i], --a[i];
    if (m == 1)
        submit();
    if (m == n)
        solve_0(0, check) ? print() : NO();
    if (m + 1 == n)
        solve_1(0, 1, check) ? print() : NO();
    if (m & 1)
    {
        for (int i = 0; i != n; ++i)
            if ((a[i] ^ i) & 1)
                NO();
        if (m == 3)
        {
            for (int i = 0; i != n; ++i)
                for (int j = n - 3; j >= 0; --j)
                    if (a[j] > a[j + 2])
                        reverse(j);
            submit();
        }
        down(m + 3);
        if (n == m + 2)
            odd::solve_2();
        else
            odd::solve_3();
        submit();
    }
    else
    {
        down(m + 2);
        if (calc(any))
            reverse(0);
        solve_2(shifto);
        submit();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 3392kb

input:

1 1 1
1

output:

0

result:

ok Perfect :) Use 0 operations

Test #2:

score: 5
Accepted
time: 2ms
memory: 3564kb

input:

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

output:

0

result:

ok Perfect :) Use 0 operations

Test #3:

score: 5
Accepted
time: 2ms
memory: 3464kb

input:

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

output:

-1

result:

ok No solutions

Test #4:

score: 5
Accepted
time: 2ms
memory: 3456kb

input:

1 4 3
1 2 3 4

output:

0

result:

ok Perfect :) Use 0 operations

Test #5:

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

input:

1 5 3
5 2 1 4 3

output:

2
0
2

result:

ok Perfect :) Use 2 operations

Test #6:

score: 5
Accepted
time: 2ms
memory: 3492kb

input:

1 5 3
3 2 1 4 5

output:

1
0

result:

ok Perfect :) Use 1 operations

Test #7:

score: 5
Accepted
time: 2ms
memory: 3448kb

input:

1 5 3
5 2 3 4 1

output:

3
2
0
2

result:

ok Perfect :) Use 3 operations

Test #8:

score: 5
Accepted
time: 1ms
memory: 3560kb

input:

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

output:

15
6
5
4
3
2
1
0
7
4
3
2
5
4
7
6

result:

ok Perfect :) Use 15 operations

Test #9:

score: 5
Accepted
time: 3ms
memory: 3516kb

input:

1 5 5
5 4 3 2 1

output:

1
0

result:

ok Perfect :) Use 1 operations

Test #10:

score: 5
Accepted
time: 2ms
memory: 3632kb

input:

1 6 5
5 6 1 2 3 4

output:

4
0
1
0
1

result:

ok Perfect :) Use 4 operations

Test #11:

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

input:

1 6 5
3 2 1 4 5 6

output:

-1

result:

ok No solutions

Test #12:

score: 5
Accepted
time: 2ms
memory: 3456kb

input:

1 6 5
6 5 4 3 2 1

output:

-1

result:

ok No solutions

Test #13:

score: 5
Accepted
time: 2ms
memory: 3448kb

input:

1 7 5
3 2 7 6 1 4 5

output:

9
1
1
0
2
1
1
0
0
1

result:

ok Perfect :) Use 9 operations

Test #14:

score: 5
Accepted
time: 2ms
memory: 3504kb

input:

1 7 5
5 2 7 4 3 6 1

output:

-1

result:

ok No solutions

Test #15:

score: 5
Accepted
time: 2ms
memory: 3520kb

input:

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

output:

26
4
5
4
4
4
1
1
0
1
2
1
0
2
1
1
0
1
0
3
2
0
1
2
3
0
1

result:

ok Perfect :) Use 26 operations

Test #16:

score: 5
Accepted
time: 2ms
memory: 3552kb

input:

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

output:

-1

result:

ok No solutions

Test #17:

score: 5
Accepted
time: 2ms
memory: 3452kb

input:

1 9 7
7 8 5 6 9 4 1 2 3

output:

17
1
1
0
1
2
1
0
1
0
1
0
1
2
1
0
1
0

result:

ok Perfect :) Use 17 operations

Test #18:

score: 5
Accepted
time: 1ms
memory: 3452kb

input:

1 9 7
1 6 9 8 3 2 5 4 7

output:

-1

result:

ok No solutions

Test #19:

score: 5
Accepted
time: 2ms
memory: 3564kb

input:

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

output:

34
0
1
1
0
1
2
1
0
1
0
1
2
1
0
2
1
1
0
1
0
3
2
3
2
1
0
2
3
3
2
1
0
2
3

result:

ok Perfect :) Use 34 operations

Test #20:

score: 5
Accepted
time: 2ms
memory: 3460kb

input:

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

output:

2
0
1

result:

ok Perfect :) Use 2 operations

Subtask #2:

score: 5
Accepted

Test #21:

score: 5
Accepted
time: 2ms
memory: 3464kb

input:

2 2 2
2 1

output:

1
0

result:

ok Perfect :) Use 1 operations

Test #22:

score: 5
Accepted
time: 2ms
memory: 3448kb

input:

2 3 2
1 3 2

output:

5
0
1
0
1
0

result:

ok Perfect :) Use 5 operations

Test #23:

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

input:

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

output:

35
8
8
1
2
3
4
5
6
7
7
7
5
6
6
6
3
4
5
5
5
3
4
4
4
3
3
0
2
1
1
0
2
1
1
0

result:

ok Perfect :) Use 35 operations

Test #24:

score: 5
Accepted
time: 2ms
memory: 3388kb

input:

2 4 4
1 2 3 4

output:

0

result:

ok Perfect :) Use 0 operations

Test #25:

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

input:

2 5 4
1 5 4 3 2

output:

9
0
1
0
1
0
1
0
1
0

result:

ok Perfect :) Use 9 operations

Test #26:

score: 5
Accepted
time: 2ms
memory: 3448kb

input:

2 4 4
3 4 1 2

output:

-1

result:

ok No solutions

Test #27:

score: 5
Accepted
time: 2ms
memory: 3452kb

input:

2 5 4
4 5 2 3 1

output:

-1

result:

ok No solutions

Test #28:

score: 5
Accepted
time: 2ms
memory: 3624kb

input:

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

output:

46
2
5
6
5
6
4
5
4
5
4
3
4
2
3
2
3
1
0
1
0
1
2
1
2
1
0
1
0
1
2
1
2
1
0
1
2
1
2
1
2
2
1
1
0
1
0

result:

ok Perfect :) Use 46 operations

Test #29:

score: 5
Accepted
time: 2ms
memory: 3520kb

input:

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

output:

-1

result:

ok No solutions

Test #30:

score: 5
Accepted
time: 2ms
memory: 3388kb

input:

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

output:

77
3
4
2
4
2
3
1
3
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
2
1
2
1
2
1
2
1
0
1
2
1
2
1
2
1
2
1
2
1
2
0
1
1
2
1
2
1
2
0
1
0
1
0
1
2
1
2
1
2
1

result:

ok Perfect :) Use 77 operations

Test #31:

score: 5
Accepted
time: 2ms
memory: 3460kb

input:

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

output:

78
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
2
0
1
0
1
0
1
1
2
0
1
0
1
0
1
1
2
1
2
1
2
1
2
2
1
1
0
1
0
1
0
1
0
2
1
2
1
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
2
1
2
1
2
1
2
1
2

result:

ok Perfect :) Use 78 operations

Test #32:

score: 5
Accepted
time: 1ms
memory: 3460kb

input:

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

output:

78
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
2
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
0
1
0
1
1
2
1
2
1
2
0
1
1
2
1
2
1
2
1
2
1
0
1
2
2
1
1
0
1
0
1
0
1
0

result:

ok Perfect :) Use 78 operations

Test #33:

score: 5
Accepted
time: 2ms
memory: 3620kb

input:

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

output:

-1

result:

ok No solutions

Test #34:

score: 5
Accepted
time: 2ms
memory: 3460kb

input:

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

output:

1
0

result:

ok Perfect :) Use 1 operations

Test #35:

score: 5
Accepted
time: 2ms
memory: 3612kb

input:

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

output:

-1

result:

ok No solutions

Subtask #3:

score: 5
Accepted

Test #36:

score: 5
Accepted
time: 2ms
memory: 3644kb

input:

3 30 29
19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 30 29 28 27 26 25 24 23 22 21 20

output:

11
0
1
0
1
0
1
0
1
0
1
0

result:

ok Perfect :) Use 11 operations

Test #37:

score: 5
Accepted
time: 2ms
memory: 3496kb

input:

3 30 29
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 2 3 4 5

output:

-1

result:

ok No solutions

Test #38:

score: 5
Accepted
time: 2ms
memory: 3580kb

input:

3 29 29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

output:

0

result:

ok Perfect :) Use 0 operations

Test #39:

score: 5
Accepted
time: 2ms
memory: 3388kb

input:

3 29 29
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1 2 3 4 5 6 7 8 9 10 11 12

output:

-1

result:

ok No solutions

Test #40:

score: 5
Accepted
time: 2ms
memory: 3584kb

input:

3 29 27
29 6 23 4 19 2 7 28 5 26 13 24 9 22 15 20 3 18 25 16 1 14 17 12 27 10 21 8 11

output:

223
1
0
1
0
1
0
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
...

result:

ok Perfect :) Use 223 operations

Test #41:

score: 5
Accepted
time: 2ms
memory: 3472kb

input:

3 29 27
1 16 21 14 9 12 29 10 5 8 27 6 15 4 13 2 11 28 23 26 7 24 3 22 17 20 19 18 25

output:

-1

result:

ok No solutions

Test #42:

score: 5
Accepted
time: 2ms
memory: 3644kb

input:

3 30 27
29 16 15 22 13 20 21 24 27 8 5 10 23 18 9 28 1 26 3 14 7 4 25 2 11 12 17 30 19 6

output:

299
0
1
0
1
2
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
2
1
1
0
1
0
1
0
1
0
3
...

result:

ok Perfect :) Use 299 operations

Test #43:

score: 5
Accepted
time: 2ms
memory: 3460kb

input:

3 30 27
19 18 29 22 5 12 13 24 7 4 1 20 11 2 3 30 25 16 27 8 17 6 21 26 23 28 9 14 15 10

output:

383
1
0
1
0
1
0
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 383 operations

Test #44:

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

input:

3 27 25
7 24 3 22 25 20 11 18 1 16 9 14 13 12 15 10 19 8 17 6 27 4 5 2 21 26 23

output:

121
1
0
1
0
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
2
1
2
1
2
1
1
0
2
1
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
0
2
1
2
1
2
1
1
0
1
2
1
0
1
0
1
0

result:

ok Perfect :) Use 121 operations

Test #45:

score: 5
Accepted
time: 1ms
memory: 3456kb

input:

3 27 25
21 26 9 2 19 4 5 6 27 8 17 10 3 12 11 14 15 16 13 18 25 20 1 22 23 24 7

output:

-1

result:

ok No solutions

Test #46:

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

input:

3 30 25
7 10 25 6 15 14 19 22 9 12 11 28 27 16 5 24 17 4 21 2 13 20 1 30 29 8 3 18 23 26

output:

275
2
5
4
4
4
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
1
0
2
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
2
...

result:

ok Perfect :) Use 275 operations

Test #47:

score: 5
Accepted
time: 2ms
memory: 3520kb

input:

3 30 25
13 6 29 16 7 24 19 20 17 18 3 28 27 4 9 22 1 26 21 8 15 10 5 2 25 12 23 14 11 30

output:

-1

result:

ok No solutions

Test #48:

score: 5
Accepted
time: 2ms
memory: 3520kb

input:

3 25 23
21 8 13 10 1 12 19 14 23 16 25 18 15 20 11 22 5 24 7 2 3 4 17 6 9

output:

154
0
1
0
1
0
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
...

result:

ok Perfect :) Use 154 operations

Test #49:

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

input:

3 25 23
23 12 21 14 13 16 19 18 25 20 3 22 9 24 17 2 5 4 15 6 11 8 1 10 7

output:

-1

result:

ok No solutions

Test #50:

score: 5
Accepted
time: 2ms
memory: 3464kb

input:

3 30 23
5 28 15 12 1 18 17 4 21 10 23 22 19 24 29 2 25 6 3 8 13 26 9 16 11 14 27 20 7 30

output:

207
7
7
6
5
6
5
6
5
6
5
6
5
1
3
5
4
3
4
3
4
3
4
3
4
3
0
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
2
1
1
0
1
0
1
2
1
0
2
1
2
1
2
1
1
0
1
0
3
2
3
2
3
2
3
2
3
2
2
3
1
0
1
0
2
3
2
3
1
0
1
0
1
0
3
2
1
0
2
...

result:

ok Perfect :) Use 207 operations

Test #51:

score: 5
Accepted
time: 2ms
memory: 3388kb

input:

3 23 21
3 12 11 14 15 16 21 18 7 20 9 22 17 2 5 4 1 6 13 8 23 10 19

output:

88
1
0
1
2
1
0
0
1
0
1
0
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
2
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1

result:

ok Perfect :) Use 88 operations

Test #52:

score: 5
Accepted
time: 2ms
memory: 3580kb

input:

3 23 21
19 8 21 10 17 12 1 14 13 16 15 18 11 20 9 22 23 2 7 4 5 6 3

output:

-1

result:

ok No solutions

Test #53:

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

input:

3 30 21
15 24 3 12 25 22 19 10 1 8 17 2 27 4 23 18 9 16 29 28 13 14 7 20 11 26 5 30 21 6

output:

165
8
9
4
8
7
7
7
6
5
6
5
6
5
6
5
1
5
3
4
1
0
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
2
1
2
1
1
0
1
0
1
2
1
2
1
0
1
0
1
2
1
0
2
1
1
0
1
0
2
3
2
3
2
3
0
1
3
2
1
0
2
3
3
2
1
0
2
3
2
3
2
3
2
3
2
3
1
0
1
0
1
0
1
0
1
0
3
2
3
2
0
1
3
2
3
2
3
2
3
2
3
2
0
1
0
1
0
1
0
1
3
2
3
...

result:

ok Perfect :) Use 165 operations

Test #54:

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

input:

3 30 21
1 26 15 22 27 6 3 14 19 24 21 16 29 4 17 12 7 10 13 20 23 2 9 30 5 28 11 18 25 8

output:

-1

result:

ok No solutions

Test #55:

score: 5
Accepted
time: 2ms
memory: 3560kb

input:

3 30 5
9 2 5 20 7 4 19 16 11 24 15 8 1 30 17 22 3 26 29 28 13 10 25 6 21 12 23 18 27 14

output:

92
13
17
21
25
25
25
20
24
24
24
19
23
23
23
21
22
13
17
21
21
21
19
20
9
13
17
18
19
17
18
15
16
17
15
16
3
7
11
15
15
15
4
8
12
13
14
13
13
11
12
3
7
11
11
11
10
10
7
8
9
8
8
8
7
7
7
6
6
4
5
0
4
4
4
1
0
1
0
1
2
1
0
1
0
1
0
0
1
2
3
0
1

result:

ok Perfect :) Use 92 operations

Subtask #4:

score: 5
Accepted

Test #56:

score: 5
Accepted
time: 2ms
memory: 3472kb

input:

4 30 30
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

output:

0

result:

ok Perfect :) Use 0 operations

Test #57:

score: 5
Accepted
time: 1ms
memory: 3576kb

input:

4 30 30
20 23 4 16 27 18 7 9 19 11 2 28 14 25 26 30 13 1 10 6 12 17 3 8 5 15 22 29 21 24

output:

-1

result:

ok No solutions

Test #58:

score: 5
Accepted
time: 2ms
memory: 3452kb

input:

4 30 30
24 25 26 27 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

output:

-1

result:

ok No solutions

Test #59:

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

input:

4 29 28
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1

output:

30
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

result:

ok Perfect :) Use 30 operations

Test #60:

score: 5
Accepted
time: 2ms
memory: 3524kb

input:

4 29 28
4 3 12 18 13 9 2 19 10 14 21 25 5 6 22 20 27 7 16 23 28 11 26 29 24 17 15 8 1

output:

-1

result:

ok No solutions

Test #61:

score: 5
Accepted
time: 2ms
memory: 3468kb

input:

4 30 28
26 6 10 15 22 5 4 13 11 1 14 18 29 9 30 12 8 3 19 20 2 24 28 21 25 23 16 7 27 17

output:

828
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
2
1
2
1
2
1
2
1
2
1
2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
...

result:

ok Perfect :) Use 828 operations

Test #62:

score: 5
Accepted
time: 2ms
memory: 3464kb

input:

4 30 28
29 1 10 8 4 21 24 27 23 15 25 20 17 16 3 22 30 13 5 12 26 14 19 6 2 9 28 11 18 7

output:

834
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 834 operations

Test #63:

score: 5
Accepted
time: 1ms
memory: 3464kb

input:

4 30 28
6 25 22 17 12 18 20 3 29 27 5 2 21 9 24 19 15 10 26 16 30 14 7 28 8 11 23 13 1 4

output:

892
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
0
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 892 operations

Test #64:

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

input:

4 30 28
30 10 12 18 21 14 15 17 2 29 27 25 24 26 23 16 1 8 3 22 28 9 19 6 7 20 5 13 4 11

output:

-1

result:

ok No solutions

Test #65:

score: 5
Accepted
time: 2ms
memory: 3600kb

input:

4 30 26
28 10 13 6 21 2 29 23 30 3 26 5 18 16 7 27 11 15 19 14 20 25 1 4 8 9 12 24 17 22

output:

737
4
2
4
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 737 operations

Test #66:

score: 5
Accepted
time: 2ms
memory: 3468kb

input:

4 30 26
11 28 19 26 1 5 20 25 9 30 12 4 15 16 2 17 29 6 10 3 13 7 21 24 23 18 8 27 14 22

output:

792
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
2
3
2
3
2
3
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 792 operations

Test #67:

score: 5
Accepted
time: 2ms
memory: 3624kb

input:

4 30 2
4 14 8 28 29 17 13 2 12 22 25 10 11 21 16 3 6 18 30 7 26 23 24 15 5 9 27 1 20 19

output:

269
18
19
20
21
22
23
24
25
26
27
28
28
28
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
27
27
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
26
26
23
24
25
25
25
17
18
19
20
21
22
23
24
24
24
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
23
23
17
18
19
20
21
22...

result:

ok Perfect :) Use 269 operations

Test #68:

score: 5
Accepted
time: 2ms
memory: 3524kb

input:

4 30 4
5 22 28 8 13 16 4 24 20 19 27 3 15 18 9 25 10 7 21 30 11 1 29 23 14 2 26 12 17 6

output:

158
19
22
25
26
25
26
19
22
25
25
25
2
5
8
11
14
17
20
23
24
23
24
9
12
15
18
21
22
23
18
21
22
21
22
17
20
21
20
21
6
9
12
15
18
19
20
16
19
19
19
1
4
7
10
13
16
17
18
14
17
17
17
6
9
12
15
16
15
16
8
11
14
15
14
15
5
8
11
14
14
14
13
13
13
3
6
9
12
12
12
4
7
10
11
10
11
4
7
10
10
10
2
5
8
9
8
9
7
...

result:

ok Perfect :) Use 158 operations

Test #69:

score: 5
Accepted
time: 2ms
memory: 3452kb

input:

4 30 4
4 17 23 18 3 8 19 16 29 7 2 10 5 11 9 15 26 12 1 27 21 14 22 30 6 20 28 24 13 25

output:

-1

result:

ok No solutions

Test #70:

score: 5
Accepted
time: 1ms
memory: 3396kb

input:

4 30 6
20 10 19 9 12 7 6 22 29 28 13 3 30 14 8 21 5 25 16 15 17 2 4 27 18 1 26 24 11 23

output:

130
12
17
22
23
24
8
13
18
23
23
23
12
17
22
22
22
21
21
19
20
9
14
19
19
19
17
18
17
15
17
7
12
14
16
8
13
14
15
0
5
10
12
14
3
8
13
13
13
12
10
12
8
11
10
11
5
10
10
10
8
9
7
8
6
8
3
5
7
1
6
6
6
5
4
5
1
4
3
4
2
3
1
3
0
1
0
1
0
1
0
2
1
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
2
1
2
1
2
1
2
1
0
1
2
1
2
1
2
0
1...

result:

ok Perfect :) Use 130 operations

Subtask #5:

score: 15
Accepted

Test #71:

score: 15
Accepted
time: 2ms
memory: 3520kb

input:

5 50 49
37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 50 49 48 47 46 45 44 43 42 41 40 39 38

output:

13
0
1
0
1
0
1
0
1
0
1
0
1
0

result:

ok Perfect :) Use 13 operations

Test #72:

score: 15
Accepted
time: 2ms
memory: 3612kb

input:

5 50 49
37 16 13 38 27 32 11 36 7 42 33 12 19 50 23 18 9 8 39 2 3 26 47 10 5 44 17 46 1 20 41 4 31 34 49 22 45 40 29 30 43 24 15 6 21 28 25 14 35 48

output:

-1

result:

ok No solutions

Test #73:

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

input:

5 50 49
50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

-1

result:

ok No solutions

Test #74:

score: 15
Accepted
time: 2ms
memory: 3524kb

input:

5 50 49
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

output:

-1

result:

ok No solutions

Test #75:

score: 15
Accepted
time: 1ms
memory: 3640kb

input:

5 49 49
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

output:

0

result:

ok Perfect :) Use 0 operations

Test #76:

score: 15
Accepted
time: 2ms
memory: 3464kb

input:

5 49 49
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

output:

-1

result:

ok No solutions

Test #77:

score: 15
Accepted
time: 2ms
memory: 3624kb

input:

5 49 47
25 40 49 38 3 36 27 34 13 32 23 30 7 28 15 26 19 24 37 22 5 20 41 18 35 16 43 14 29 12 39 10 31 8 9 6 1 4 17 2 47 48 45 46 21 44 11 42 33

output:

469
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
2
1
0
1
0
1
2
1
0
1
0
1
0
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
...

result:

ok Perfect :) Use 469 operations

Test #78:

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

input:

5 49 47
47 20 49 16 43 34 35 22 19 28 37 30 17 36 11 4 21 32 33 6 1 26 29 40 25 8 23 14 9 44 31 42 3 24 45 12 15 2 27 10 7 46 41 38 13 48 39 18 5

output:

-1

result:

ok No solutions

Test #79:

score: 15
Accepted
time: 2ms
memory: 3524kb

input:

5 49 47
23 44 31 46 15 48 25 2 45 4 43 6 11 8 47 10 5 12 3 14 21 16 9 18 29 20 13 22 17 24 39 26 35 28 19 30 27 32 49 34 1 36 7 38 33 40 37 42 41

output:

-1

result:

ok No solutions

Test #80:

score: 15
Accepted
time: 2ms
memory: 3464kb

input:

5 50 47
41 30 47 28 23 8 13 50 25 22 1 26 11 46 3 20 7 12 15 32 27 14 43 36 37 42 29 2 49 44 21 34 5 48 19 18 17 24 31 10 35 40 9 6 45 4 33 38 39 16

output:

992
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 992 operations

Test #81:

score: 15
Accepted
time: 2ms
memory: 3600kb

input:

5 50 47
37 30 25 14 15 40 41 44 17 10 43 28 13 12 39 38 11 34 31 32 1 16 19 24 23 20 21 4 3 22 7 46 47 2 29 50 5 42 33 26 45 18 35 6 9 36 27 48 49 8

output:

754
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
...

result:

ok Perfect :) Use 754 operations

Test #82:

score: 15
Accepted
time: 2ms
memory: 3536kb

input:

5 50 47
5 16 11 48 17 26 37 28 47 10 27 2 21 4 35 20 3 12 31 44 19 8 15 40 13 30 23 6 39 24 41 46 29 42 45 50 9 14 1 38 33 34 7 18 43 36 49 22 25 32

output:

908
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
...

result:

ok Perfect :) Use 908 operations

Test #83:

score: 15
Accepted
time: 2ms
memory: 3500kb

input:

5 50 47
2 27 45 5 49 23 21 10 3 30 6 9 37 29 38 18 31 43 46 28 15 39 22 44 50 48 16 34 8 11 36 17 41 33 32 47 19 35 24 14 1 26 40 12 25 13 7 42 20 4

output:

-1

result:

ok No solutions

Test #84:

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

input:

5 47 45
23 12 47 14 5 16 43 18 39 20 27 22 15 24 25 26 17 28 31 30 3 32 11 34 35 36 37 38 9 40 29 42 19 44 7 46 41 2 21 4 45 6 13 8 33 10 1

output:

432
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
...

result:

ok Perfect :) Use 432 operations

Test #85:

score: 15
Accepted
time: 2ms
memory: 3464kb

input:

5 47 45
23 38 47 36 21 34 43 32 1 30 27 28 7 26 5 24 9 22 33 20 31 18 45 16 17 14 37 12 3 10 11 8 13 6 15 4 41 2 39 46 19 44 29 42 35 40 25

output:

-1

result:

ok No solutions

Test #86:

score: 15
Accepted
time: 2ms
memory: 3624kb

input:

5 50 45
7 36 23 6 37 14 17 24 19 28 1 18 25 10 45 20 41 42 49 22 13 12 15 30 33 34 11 40 35 32 21 48 47 38 43 46 29 16 27 4 3 8 5 26 31 2 39 50 9 44

output:

774
4
5
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 774 operations

Test #87:

score: 15
Accepted
time: 2ms
memory: 3520kb

input:

5 50 45
11 10 19 8 3 42 1 14 41 36 13 24 21 30 7 40 29 2 17 48 35 22 45 12 31 50 15 18 5 6 37 20 49 28 23 38 27 34 39 26 33 16 9 46 47 4 43 44 25 32

output:

-1

result:

ok No solutions

Test #88:

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

input:

5 45 43
5 14 9 12 41 10 27 8 7 6 39 4 1 2 45 44 35 42 37 40 21 38 13 36 31 34 3 32 19 30 23 28 17 26 29 24 25 22 11 20 15 18 33 16 43

output:

323
1
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 323 operations

Test #89:

score: 15
Accepted
time: 2ms
memory: 3524kb

input:

5 45 43
21 20 3 22 9 24 41 26 1 28 45 30 13 32 23 34 5 36 31 38 25 40 37 42 7 44 43 2 39 4 35 6 33 8 15 10 19 12 17 14 11 16 29 18 27

output:

-1

result:

ok No solutions

Test #90:

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

input:

5 50 43
39 10 37 38 27 24 29 16 35 6 15 8 49 40 9 2 19 30 31 22 21 42 47 18 43 48 1 34 41 4 11 12 17 36 25 14 7 26 5 32 45 20 3 46 23 28 33 44 13 50

output:

805
7
7
6
5
6
5
6
5
6
5
5
4
5
4
5
4
5
4
5
4
5
4
5
4
3
4
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
...

result:

ok Perfect :) Use 805 operations

Test #91:

score: 15
Accepted
time: 2ms
memory: 3572kb

input:

5 43 41
19 18 9 16 17 14 43 12 39 10 13 8 23 6 7 4 31 2 3 42 33 40 11 38 41 36 29 34 25 32 37 30 5 28 15 26 21 24 35 22 27 20 1

output:

285
1
1
0
1
0
1
0
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
...

result:

ok Perfect :) Use 285 operations

Test #92:

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

input:

5 43 41
33 2 17 4 21 6 11 8 25 10 43 12 41 14 35 16 13 18 3 20 9 22 19 24 27 26 31 28 37 30 39 32 15 34 1 36 5 38 23 40 29 42 7

output:

-1

result:

ok No solutions

Test #93:

score: 15
Accepted
time: 2ms
memory: 3532kb

input:

5 50 41
1 14 23 28 7 48 43 12 17 2 5 36 9 6 33 8 37 40 47 30 13 20 45 18 3 22 35 38 21 32 27 50 29 42 31 44 49 34 39 4 15 10 41 46 11 16 19 24 25 26

output:

773
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
7
8
7
8
7
5
6
7
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
...

result:

ok Perfect :) Use 773 operations

Test #94:

score: 15
Accepted
time: 2ms
memory: 3556kb

input:

5 50 41
31 24 33 20 43 30 47 14 25 50 9 32 41 12 23 34 45 22 11 4 17 36 3 10 35 6 15 18 5 26 39 46 37 40 49 42 27 38 7 44 21 8 13 28 1 16 29 48 19 2

output:

-1

result:

ok No solutions

Test #95:

score: 15
Accepted
time: 2ms
memory: 3588kb

input:

5 50 41
43 2 49 24 37 26 33 18 29 36 3 50 25 42 1 48 47 28 23 32 19 40 11 16 45 4 27 44 9 8 13 30 41 46 31 38 21 10 39 20 17 34 15 12 7 6 5 14 35 22

output:

-1

result:

ok No solutions

Test #96:

score: 15
Accepted
time: 1ms
memory: 3520kb

input:

5 50 41
7 44 29 26 9 48 41 16 17 8 35 36 15 14 11 10 1 50 25 4 37 46 21 18 39 40 23 12 47 38 43 30 3 22 49 32 13 6 19 24 33 28 27 42 5 34 31 20 45 2

output:

-1

result:

ok No solutions

Test #97:

score: 15
Accepted
time: 2ms
memory: 3640kb

input:

5 50 1
9 36 49 22 31 14 27 42 5 38 19 26 15 6 41 40 13 18 37 50 25 30 47 32 11 20 3 2 43 24 17 44 39 12 23 10 1 46 21 16 29 34 7 48 33 28 35 4 45 8

output:

-1

result:

ok No solutions

Test #98:

score: 15
Accepted
time: 2ms
memory: 3532kb

input:

5 50 3
11 46 27 30 25 2 21 50 35 6 17 36 1 28 5 20 33 10 37 14 9 24 29 48 43 12 13 40 39 16 47 18 41 34 3 44 31 22 19 4 45 32 49 26 23 42 15 8 7 38

output:

278
46
45
44
43
42
41
40
38
37
36
35
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
11
10
9
8
7
6
4
3
2
1
0
47
46
44
43
42
40
39
38
37
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
15
13
12
10
9
8
6
5
4
3
2
46
44
40
39
37
36
34
32
31
28
27
26
25
23
22
20
19
17
15
14
12
11
...

result:

ok Perfect :) Use 278 operations

Test #99:

score: 15
Accepted
time: 2ms
memory: 3460kb

input:

5 50 5
19 24 23 42 15 22 25 40 11 4 41 34 7 48 9 6 5 8 33 2 43 20 37 28 27 10 3 50 17 44 39 26 47 16 35 14 31 46 45 18 21 32 29 36 1 38 13 12 49 30

output:

231
27
31
35
39
43
44
45
44
44
44
13
17
21
25
29
33
37
41
42
43
36
40
41
42
33
37
41
41
41
36
40
40
40
25
29
33
37
38
39
18
22
26
30
34
38
38
38
3
7
11
15
19
23
27
31
35
36
37
8
12
16
20
24
28
32
36
36
36
3
7
11
15
19
23
27
31
35
35
35
28
32
33
34
32
33
24
28
32
32
32
21
25
29
30
31
22
26
30
30
30
3...

result:

ok Perfect :) Use 231 operations

Test #100:

score: 15
Accepted
time: 2ms
memory: 3500kb

input:

5 50 5
47 30 5 38 21 24 41 12 3 26 25 28 29 18 45 40 49 10 15 2 1 36 37 42 35 32 9 44 7 6 19 8 23 16 27 22 31 20 11 4 39 46 17 50 13 48 43 14 33 34

output:

-1

result:

ok No solutions

Subtask #6:

score: 5
Accepted

Test #101:

score: 5
Accepted
time: 2ms
memory: 3612kb

input:

6 50 50
50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

1
0

result:

ok Perfect :) Use 1 operations

Test #102:

score: 5
Accepted
time: 2ms
memory: 3640kb

input:

6 50 50
29 35 5 48 19 9 24 14 7 20 27 30 32 23 18 42 26 38 36 16 28 39 33 40 34 4 43 13 17 47 15 46 41 8 11 49 45 50 25 3 10 21 37 44 22 6 1 31 2 12

output:

-1

result:

ok No solutions

Test #103:

score: 5
Accepted
time: 1ms
memory: 3464kb

input:

6 50 50
39 40 41 42 43 44 45 46 47 48 49 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

output:

-1

result:

ok No solutions

Test #104:

score: 5
Accepted
time: 2ms
memory: 3388kb

input:

6 49 48
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

output:

32
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

result:

ok Perfect :) Use 32 operations

Test #105:

score: 5
Accepted
time: 2ms
memory: 3396kb

input:

6 49 48
45 12 30 24 16 21 2 47 42 36 34 14 26 33 48 23 29 9 10 25 18 13 22 38 43 40 37 27 39 32 11 19 31 1 4 46 8 35 3 17 6 5 41 20 28 7 49 15 44

output:

-1

result:

ok No solutions

Test #106:

score: 5
Accepted
time: 2ms
memory: 3668kb

input:

6 50 48
10 16 4 11 20 45 21 3 27 22 32 29 25 1 50 47 9 49 17 6 13 14 35 38 36 41 33 24 34 26 8 23 12 40 15 39 2 46 31 5 48 37 18 28 19 30 42 43 7 44

output:

2392
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1...

result:

ok Perfect :) Use 2392 operations

Test #107:

score: 5
Accepted
time: 2ms
memory: 3556kb

input:

6 50 48
26 48 43 46 33 29 34 16 21 27 32 6 11 47 18 7 19 36 1 2 35 4 23 5 3 9 41 12 8 13 44 14 10 20 17 22 50 37 15 39 49 31 28 30 42 40 45 24 25 38

output:

2376
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1...

result:

ok Perfect :) Use 2376 operations

Test #108:

score: 5
Accepted
time: 2ms
memory: 3616kb

input:

6 50 48
4 8 11 38 33 48 40 39 1 50 19 18 13 22 45 47 24 12 43 16 32 35 34 17 46 21 15 9 42 3 25 14 41 37 30 5 7 27 29 6 49 26 10 20 23 2 31 36 44 28

output:

2380
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0...

result:

ok Perfect :) Use 2380 operations

Test #109:

score: 5
Accepted
time: 2ms
memory: 3484kb

input:

6 50 48
49 34 26 39 31 12 44 46 42 36 17 2 45 7 8 40 1 22 47 10 33 32 9 43 6 23 21 50 48 3 19 41 18 15 35 38 20 11 16 4 27 37 5 24 28 14 30 25 29 13

output:

-1

result:

ok No solutions

Test #110:

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

input:

6 50 46
19 41 36 46 39 38 31 4 6 45 13 48 33 29 9 17 2 18 28 12 26 44 37 1 49 11 34 43 47 35 7 21 5 30 25 16 27 23 32 15 10 24 22 42 8 20 40 3 14 50

output:

2217
4
4
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
2
1...

result:

ok Perfect :) Use 2217 operations

Test #111:

score: 5
Accepted
time: 2ms
memory: 3672kb

input:

6 50 46
43 28 48 7 8 1 6 35 24 14 20 10 17 49 32 34 25 26 45 4 12 16 15 37 18 11 44 13 42 38 33 40 31 22 47 29 2 9 50 23 46 36 19 3 5 41 21 39 30 27

output:

2235
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
0
1
0
1
0...

result:

ok Perfect :) Use 2235 operations

Test #112:

score: 5
Accepted
time: 2ms
memory: 3468kb

input:

6 50 2
47 20 38 22 33 43 39 32 15 9 2 29 1 36 8 48 17 40 21 18 42 44 49 19 25 26 4 34 37 23 14 50 27 31 16 5 24 46 7 3 12 30 10 41 45 13 35 28 11 6

output:

779
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
48
48
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
47
47
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
46
46
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...

result:

ok Perfect :) Use 779 operations

Test #113:

score: 5
Accepted
time: 2ms
memory: 3620kb

input:

6 50 4
39 49 12 2 46 15 35 50 18 13 38 43 45 34 26 47 20 23 17 21 25 30 31 7 4 10 29 9 24 22 36 11 42 40 1 5 48 16 6 3 28 44 27 19 32 33 37 8 41 14

output:

-1

result:

ok No solutions

Test #114:

score: 5
Accepted
time: 2ms
memory: 3568kb

input:

6 50 4
32 33 36 26 11 31 20 9 6 49 14 2 7 3 42 34 37 24 19 38 39 22 30 5 43 10 12 27 46 25 8 45 50 47 35 41 48 13 4 23 29 17 15 40 1 18 44 16 21 28

output:

312
32
35
38
41
44
45
46
9
12
15
18
21
24
27
30
33
36
39
42
45
45
45
38
41
44
44
44
35
38
41
42
43
29
32
35
38
41
42
41
42
29
32
35
38
41
41
41
38
39
40
21
24
27
30
33
36
39
39
39
13
16
19
22
25
28
31
34
37
38
37
38
33
36
37
36
37
35
36
16
19
22
25
28
31
34
35
34
35
20
23
26
29
32
33
34
17
20
23
26
...

result:

ok Perfect :) Use 312 operations

Test #115:

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

input:

6 50 6
21 30 44 23 42 45 15 33 6 19 48 28 16 50 35 13 49 46 27 1 4 43 31 25 10 32 29 37 38 47 40 34 20 39 9 7 18 3 22 8 5 26 12 36 14 2 24 11 17 41

output:

283
13
18
23
28
33
38
43
44
42
44
15
20
25
30
35
40
43
42
43
10
15
20
25
30
35
40
41
42
32
37
39
41
11
16
21
26
31
36
38
40
5
10
15
20
25
30
35
37
39
2
7
12
17
22
27
32
37
38
36
38
4
9
14
19
24
29
34
37
36
37
8
13
18
23
28
33
36
35
36
33
35
28
33
34
32
34
21
26
31
32
33
16
21
26
31
32
30
32
15
20
25...

result:

ok Perfect :) Use 283 operations

Subtask #7:

score: 5
Accepted

Test #116:

score: 5
Accepted
time: 1ms
memory: 3512kb

input:

7 200 199
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28...

output:

146
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

result:

ok Perfect :) Use 146 operations

Test #117:

score: 5
Accepted
time: 1ms
memory: 3464kb

input:

7 200 199
36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 200 199 198 197 196 195 194 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158 157 156 155 154 153...

output:

-1

result:

ok No solutions

Test #118:

score: 5
Accepted
time: 2ms
memory: 3640kb

input:

7 199 199
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

0

result:

ok Perfect :) Use 0 operations

Test #119:

score: 5
Accepted
time: 2ms
memory: 3524kb

input:

7 199 199
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 ...

output:

-1

result:

ok No solutions

Test #120:

score: 5
Accepted
time: 2ms
memory: 3568kb

input:

7 199 197
33 176 185 174 197 172 5 170 97 168 27 166 159 164 137 162 101 160 173 158 83 156 19 154 57 152 123 150 3 148 111 146 141 144 13 142 79 140 55 138 25 136 11 134 91 132 175 130 151 128 9 126 103 124 67 122 157 120 105 118 125 116 65 114 129 112 113 110 139 108 39 106 95 104 17 102 73 100 93...

output:

7361
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2...

result:

ok Perfect :) Use 7361 operations

Test #121:

score: 5
Accepted
time: 2ms
memory: 3496kb

input:

7 199 197
41 34 95 36 37 38 43 40 159 42 91 44 131 46 123 48 69 50 71 52 179 54 5 56 169 58 65 60 45 62 155 64 145 66 99 68 135 70 51 72 87 74 165 76 83 78 187 80 1 82 63 84 121 86 93 88 125 90 13 92 137 94 185 96 183 98 79 100 7 102 199 104 149 106 23 108 117 110 15 112 53 114 177 116 143 118 105 1...

output:

-1

result:

ok No solutions

Test #122:

score: 5
Accepted
time: 3ms
memory: 3524kb

input:

7 200 197
85 108 73 60 113 76 117 128 19 162 137 114 97 124 171 30 131 130 31 94 11 180 45 118 147 148 157 66 145 122 35 46 155 64 9 16 39 84 195 156 141 134 193 102 43 110 89 6 33 186 59 192 179 34 17 82 187 68 173 8 163 62 197 116 135 190 107 166 185 132 87 182 5 154 119 88 49 176 151 144 23 2 69 ...

output:

16803
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
...

result:

ok Perfect :) Use 16803 operations

Test #123:

score: 5
Accepted
time: 3ms
memory: 3604kb

input:

7 200 197
7 46 191 150 189 48 53 184 59 148 23 168 45 126 63 32 195 38 125 92 157 104 29 144 169 200 41 50 137 30 31 182 13 94 49 136 135 194 121 28 181 90 89 66 47 162 147 60 109 64 165 74 61 56 57 154 155 118 105 142 101 24 17 102 103 26 141 16 91 62 55 128 119 186 161 120 5 82 167 178 177 72 127 ...

output:

14622
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
...

result:

ok Perfect :) Use 14622 operations

Test #124:

score: 5
Accepted
time: 1ms
memory: 3652kb

input:

7 200 197
163 182 17 156 127 50 129 150 1 80 51 160 137 28 179 78 21 200 79 132 91 184 157 110 71 92 57 166 77 190 81 32 185 82 83 170 195 26 55 130 95 192 113 134 167 188 53 136 171 6 13 186 93 116 107 152 151 52 87 120 149 12 183 154 115 102 155 108 19 94 43 172 161 128 39 114 199 148 63 14 125 88...

output:

15529
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
...

result:

ok Perfect :) Use 15529 operations

Test #125:

score: 5
Accepted
time: 1ms
memory: 3560kb

input:

7 200 197
45 54 97 10 39 160 113 42 79 92 199 8 85 158 127 94 99 150 15 2 165 192 153 78 83 162 135 180 115 114 21 76 193 110 149 50 49 184 57 106 195 98 169 64 155 168 23 196 189 138 143 38 69 12 159 34 123 176 119 20 107 148 121 120 35 100 51 104 161 74 87 90 111 172 137 62 47 108 171 70 5 58 179 ...

output:

-1

result:

ok No solutions

Test #126:

score: 5
Accepted
time: 1ms
memory: 3632kb

input:

7 197 195
47 64 115 66 135 68 67 70 109 72 129 74 103 76 29 78 183 80 123 82 55 84 137 86 173 88 27 90 93 92 175 94 13 96 161 98 177 100 163 102 39 104 19 106 21 108 119 110 63 112 165 114 147 116 191 118 121 120 85 122 61 124 3 126 195 128 171 130 185 132 75 134 167 136 87 138 97 140 71 142 149 144...

output:

7706
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0...

result:

ok Perfect :) Use 7706 operations

Test #127:

score: 5
Accepted
time: 2ms
memory: 3560kb

input:

7 197 195
87 132 43 134 143 136 9 138 67 140 55 142 33 144 79 146 107 148 13 150 17 152 165 154 177 156 81 158 71 160 111 162 123 164 113 166 119 168 85 170 3 172 69 174 149 176 173 178 1 180 7 182 21 184 77 186 117 188 59 190 57 192 139 194 175 196 159 2 109 4 31 6 185 8 153 10 197 12 23 14 189 16 ...

output:

-1

result:

ok No solutions

Test #128:

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

input:

7 200 195
135 76 149 196 119 54 183 144 145 52 69 168 61 82 17 8 121 122 71 40 147 128 113 6 9 166 193 106 153 56 65 60 169 160 97 62 173 180 11 114 157 104 55 138 127 116 91 92 13 72 39 124 111 2 79 100 99 46 103 74 195 176 155 146 29 30 95 200 177 32 163 188 73 90 21 18 51 174 77 98 5 58 49 102 17...

output:

15362
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
0
1
0
1
0
1
0
1
0
1
0
...

result:

ok Perfect :) Use 15362 operations

Test #129:

score: 5
Accepted
time: 2ms
memory: 3532kb

input:

7 195 193
35 138 183 136 91 134 117 132 161 130 157 128 1 126 185 124 139 122 83 120 127 118 53 116 115 114 33 112 187 110 27 108 111 106 175 104 145 102 171 100 163 98 119 96 137 94 13 92 81 90 121 88 167 86 141 84 77 82 51 80 71 78 39 76 41 74 147 72 169 70 99 68 49 66 101 64 29 62 105 60 7 58 9 5...

output:

7111
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1...

result:

ok Perfect :) Use 7111 operations

Test #130:

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

input:

7 195 193
27 94 43 92 67 90 111 88 193 86 107 84 79 82 77 80 173 78 135 76 49 74 23 72 29 70 59 68 157 66 83 64 109 62 11 60 181 58 139 56 41 54 87 52 91 50 151 48 179 46 19 44 119 42 121 40 125 38 189 36 9 34 21 32 145 30 115 28 169 26 129 24 143 22 165 20 69 18 133 16 163 14 195 12 167 10 93 8 73 ...

output:

-1

result:

ok No solutions

Test #131:

score: 5
Accepted
time: 3ms
memory: 3524kb

input:

7 200 193
117 180 197 108 193 182 9 142 107 146 25 130 95 186 53 134 119 200 61 138 123 84 23 110 159 76 97 70 93 120 81 164 165 68 137 176 105 10 39 126 65 168 17 122 129 40 7 72 79 28 59 106 3 94 103 2 29 56 87 58 171 162 19 44 169 42 55 46 49 174 135 128 115 88 177 132 149 52 91 8 173 100 45 98 1...

output:

14955
7
6
7
6
7
6
7
6
7
6
7
6
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
5
4
5
4
5
4
5
4
5
4
5
4
2
3
4
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
...

result:

ok Perfect :) Use 14955 operations

Test #132:

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

input:

7 200 193
9 78 77 108 65 130 19 90 101 40 113 136 159 168 63 188 37 100 177 36 93 96 187 92 105 10 199 158 145 190 91 52 35 120 33 64 171 48 129 16 1 156 47 54 157 42 143 6 133 140 29 186 17 60 5 138 121 106 147 184 23 98 139 122 31 50 179 88 185 172 135 32 123 82 11 118 131 74 191 112 69 26 125 148...

output:

-1

result:

ok No solutions

Test #133:

score: 5
Accepted
time: 2ms
memory: 3572kb

input:

7 200 193
195 46 131 54 83 196 63 52 35 10 13 168 65 36 121 116 151 120 1 2 157 90 169 182 33 148 7 122 197 34 177 76 107 192 159 180 37 144 149 38 91 160 19 94 105 102 17 110 23 32 69 22 101 146 167 198 59 12 135 66 57 166 185 118 175 50 73 158 147 112 75 98 27 86 179 188 173 74 171 18 61 132 41 17...

output:

-1

result:

ok No solutions

Test #134:

score: 5
Accepted
time: 2ms
memory: 3528kb

input:

7 193 191
91 174 53 172 147 170 145 168 117 166 175 164 69 162 71 160 157 158 3 156 121 154 133 152 171 150 125 148 119 146 43 144 155 142 151 140 135 138 15 136 33 134 111 132 65 130 139 128 127 126 79 124 173 122 105 120 37 118 165 116 93 114 49 112 81 110 27 108 1 106 163 104 73 102 183 100 99 98...

output:

6755
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1...

result:

ok Perfect :) Use 6755 operations

Test #135:

score: 5
Accepted
time: 2ms
memory: 3592kb

input:

7 193 191
9 178 109 180 165 182 121 184 53 186 31 188 15 190 59 192 159 2 141 4 163 6 173 8 175 10 147 12 19 14 187 16 79 18 85 20 117 22 11 24 181 26 93 28 153 30 3 32 123 34 145 36 101 38 49 40 81 42 143 44 191 46 157 48 113 50 43 52 55 54 69 56 63 58 115 60 45 62 5 64 47 66 185 68 41 70 35 72 103...

output:

-1

result:

ok No solutions

Test #136:

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

input:

7 200 191
11 124 57 16 119 56 81 132 87 168 5 80 45 102 17 38 195 116 67 74 113 200 95 190 51 90 193 186 41 86 27 140 105 60 109 18 177 144 69 82 171 34 115 134 71 98 39 194 133 184 137 110 43 12 183 180 111 64 147 170 55 122 7 44 13 156 159 164 21 78 191 84 75 52 77 66 79 160 47 148 91 92 181 26 15...

output:

15712
9
8
9
8
9
8
9
8
9
8
9
8
9
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
6
7
6
7
6
7
6
7
6
7
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
...

result:

ok Perfect :) Use 15712 operations

Test #137:

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

input:

7 200 3
31 26 29 24 39 118 79 8 121 18 165 116 181 56 15 138 11 120 193 154 149 192 147 64 189 30 95 144 197 94 167 186 49 150 171 38 135 190 111 68 183 22 17 174 145 82 123 136 127 146 125 170 109 156 93 74 195 16 47 182 97 76 141 48 21 188 41 168 23 90 87 194 113 58 131 160 99 166 53 140 157 50 83...

output:

5109
197
196
194
193
192
187
186
185
184
183
181
180
179
178
177
176
175
173
172
171
170
169
168
167
166
165
164
163
162
161
160
159
158
157
156
154
153
152
151
150
149
148
147
146
145
144
142
141
140
139
138
137
136
135
134
133
132
131
130
129
128
127
126
125
124
123
122
121
120
119
118
117
116
115...

result:

ok Perfect :) Use 5109 operations

Test #138:

score: 5
Accepted
time: 2ms
memory: 3496kb

input:

7 200 5
37 114 125 112 113 158 89 78 63 180 93 122 57 106 95 154 49 160 129 98 147 172 81 96 103 142 17 150 111 82 151 56 71 80 51 168 79 192 31 130 121 140 23 110 193 132 175 84 117 146 115 46 73 166 119 178 59 64 5 26 145 28 97 126 39 70 169 164 127 50 33 30 55 38 45 90 29 102 43 6 9 22 199 58 139...

output:

2851
135
139
143
147
151
155
159
163
167
171
175
179
183
187
191
195
195
195
82
86
90
94
98
102
106
110
114
118
122
126
130
134
138
142
146
150
154
158
162
166
170
174
178
182
186
190
194
194
194
165
169
173
177
181
185
189
193
193
193
182
186
190
191
192
190
191
106
110
114
118
122
126
130
134
138
...

result:

ok Perfect :) Use 2851 operations

Test #139:

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

input:

7 200 5
21 138 185 96 111 122 77 162 133 90 141 188 63 94 167 38 157 134 47 168 155 74 95 142 179 136 27 36 153 72 181 150 103 100 151 176 81 154 101 42 165 192 75 32 145 198 55 174 65 68 93 160 109 80 71 44 199 148 193 158 173 118 53 30 163 186 61 50 13 120 59 28 97 56 5 10 1 66 187 184 11 54 131 7...

output:

-1

result:

ok No solutions

Test #140:

score: 5
Accepted
time: 2ms
memory: 3528kb

input:

7 200 7
117 26 166 20 76 81 123 82 157 6 196 155 144 79 199 40 183 194 34 97 30 111 87 121 63 57 27 19 101 137 152 73 59 28 72 64 161 110 65 128 163 83 68 189 191 15 102 38 90 162 71 124 145 18 36 75 21 37 105 67 51 42 198 160 31 5 151 168 17 58 143 130 55 33 13 49 129 164 165 142 171 116 193 16 86 ...

output:

-1

result:

ok No solutions

Subtask #8:

score: 5
Accepted

Test #141:

score: 5
Accepted
time: 2ms
memory: 3528kb

input:

8 200 200
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

0

result:

ok Perfect :) Use 0 operations

Test #142:

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

input:

8 200 200
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 1...

output:

-1

result:

ok No solutions

Test #143:

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

input:

8 199 198
123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35...

output:

275
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
...

result:

ok Perfect :) Use 275 operations

Test #144:

score: 5
Accepted
time: 2ms
memory: 3472kb

input:

8 199 198
157 10 149 46 127 180 125 190 166 35 85 58 30 39 159 192 187 172 55 79 90 74 164 124 115 106 23 188 37 92 53 28 67 138 179 11 152 196 63 136 193 103 98 142 54 44 57 5 8 31 148 107 112 101 120 176 76 191 113 131 130 51 22 116 95 155 139 14 36 96 119 60 186 169 77 32 173 100 21 88 66 87 177 ...

output:

-1

result:

ok No solutions

Test #145:

score: 5
Accepted
time: 5ms
memory: 3684kb

input:

8 200 198
1 168 27 102 42 21 10 24 87 8 106 62 38 182 170 61 138 80 93 146 100 75 22 3 49 81 95 29 149 53 187 192 199 63 132 71 84 150 85 6 44 5 124 90 151 19 50 152 181 110 41 35 9 156 197 161 129 130 185 125 162 163 131 12 66 16 195 142 171 121 134 140 172 20 174 179 37 166 13 104 107 193 135 94 5...

output:

39590
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
...

result:

ok Perfect :) Use 39590 operations

Test #146:

score: 5
Accepted
time: 5ms
memory: 3700kb

input:

8 200 198
200 83 65 16 31 112 103 142 56 24 143 161 179 128 126 184 58 4 72 21 39 6 2 118 187 22 93 114 174 59 105 7 117 158 109 165 141 37 140 145 42 119 60 181 171 62 96 85 8 68 34 191 66 136 52 1 54 10 152 71 115 101 199 79 57 198 149 26 131 173 120 73 182 124 46 86 159 40 175 91 154 113 61 3 195...

output:

39508
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
...

result:

ok Perfect :) Use 39508 operations

Test #147:

score: 5
Accepted
time: 5ms
memory: 3656kb

input:

8 200 198
101 161 97 57 105 125 191 143 24 131 71 8 56 10 64 142 94 36 119 187 102 117 137 30 196 182 133 26 145 7 83 32 60 164 121 76 4 6 70 141 115 85 35 200 198 139 81 42 193 27 80 47 186 20 112 67 152 55 53 103 130 113 154 18 45 49 39 124 50 40 88 109 22 178 111 41 13 197 118 194 180 17 77 75 17...

output:

39885
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
...

result:

ok Perfect :) Use 39885 operations

Test #148:

score: 5
Accepted
time: 5ms
memory: 3676kb

input:

8 200 196
164 197 163 132 129 181 114 191 157 46 91 58 148 119 82 182 185 4 101 52 134 77 130 7 169 42 35 123 71 2 174 156 43 168 178 5 20 170 162 73 84 97 184 161 39 104 65 155 33 193 200 19 194 76 116 150 61 186 136 135 142 153 31 144 85 158 87 66 16 57 53 3 8 105 56 81 94 89 180 75 149 54 111 34 ...

output:

39255
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
...

result:

ok Perfect :) Use 39255 operations

Test #149:

score: 5
Accepted
time: 1ms
memory: 3616kb

input:

8 200 196
97 48 188 118 37 176 122 73 10 144 77 38 175 200 61 35 106 78 7 182 135 111 157 194 53 54 147 2 34 158 21 102 79 84 99 156 50 170 132 133 90 114 129 60 134 110 25 189 181 166 104 180 174 177 52 49 126 124 88 143 113 162 44 81 195 116 142 108 64 161 19 125 59 11 145 196 187 22 1 39 87 40 93...

output:

-1

result:

ok No solutions

Test #150:

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

input:

8 200 94
65 151 130 91 106 170 59 63 176 162 98 7 129 138 58 53 81 86 150 143 134 195 66 117 144 16 26 103 180 74 186 44 148 64 54 141 121 31 43 55 190 17 4 122 79 110 159 34 194 120 136 9 108 135 189 125 173 140 97 89 188 37 171 40 184 160 104 46 56 57 75 182 178 179 92 192 77 181 139 23 39 158 62 ...

output:

10636
61
106
86
105
68
105
96
104
84
103
102
92
102
21
61
101
87
100
35
67
99
26
62
98
97
81
97
96
87
96
41
68
95
35
94
77
94
44
93
71
93
67
92
58
92
60
91
60
91
90
79
90
50
89
88
54
88
24
87
72
87
70
78
86
55
70
85
54
69
84
62
83
8
45
82
74
81
66
73
80
72
79
36
79
78
68
78
77
34
77
5
76
65
76
67
75...

result:

ok Perfect :) Use 10636 operations

Test #151:

score: 5
Accepted
time: 2ms
memory: 3560kb

input:

8 200 44
2 22 36 168 122 23 169 31 190 173 68 194 144 111 133 59 109 11 186 46 54 38 160 83 179 58 78 93 81 115 148 73 151 199 130 105 97 167 131 152 7 90 149 124 172 70 27 95 183 147 108 12 20 37 21 82 35 129 17 30 174 32 140 163 43 132 127 146 117 182 64 187 49 118 141 39 175 92 188 106 57 75 114 ...

output:

-1

result:

ok No solutions

Test #152:

score: 5
Accepted
time: 2ms
memory: 3544kb

input:

8 200 32
180 138 34 173 17 135 50 98 71 90 118 194 77 159 12 19 39 166 143 32 105 88 65 102 28 104 172 42 52 16 195 146 139 44 74 136 62 156 115 63 112 81 127 197 144 122 36 141 200 153 94 6 131 38 119 37 162 170 154 21 192 133 120 189 96 117 176 14 35 129 89 23 67 69 155 8 51 40 169 10 107 177 193 ...

output:

1878
48
79
110
141
168
166
168
158
167
159
166
43
74
105
136
165
164
165
110
141
164
160
164
30
61
92
123
154
163
152
163
11
42
73
104
135
162
160
162
79
110
141
151
161
12
43
74
105
136
148
160
143
151
159
103
134
146
158
40
71
102
133
145
157
156
149
156
149
155
124
139
154
153
138
153
112
143
152...

result:

ok Perfect :) Use 1878 operations

Test #153:

score: 5
Accepted
time: 2ms
memory: 3548kb

input:

8 200 4
171 175 118 12 130 32 77 64 153 35 36 82 5 8 100 157 49 6 76 191 109 173 39 88 80 95 66 123 21 67 74 40 17 149 46 138 194 141 132 193 2 114 38 18 198 29 87 16 4 48 41 131 126 1 3 70 75 158 108 26 31 196 170 156 192 135 62 93 144 177 72 57 140 124 150 86 172 99 189 179 85 58 24 190 20 22 200 ...

output:

-1

result:

ok No solutions

Test #154:

score: 5
Accepted
time: 2ms
memory: 3488kb

input:

8 200 4
44 33 197 167 130 22 12 72 97 102 30 155 64 105 128 196 193 29 36 5 51 75 173 121 156 32 177 161 8 52 100 144 159 148 158 42 119 125 25 149 84 15 141 85 90 74 134 55 150 4 129 151 78 135 123 48 86 21 140 174 34 104 103 98 116 69 80 60 92 163 70 11 16 27 110 2 73 185 63 68 26 170 137 172 181 ...

output:

3631
146
149
152
155
158
161
164
167
170
173
176
179
182
185
188
191
194
195
196
117
120
123
126
129
132
135
138
141
144
147
150
153
156
159
162
165
168
171
174
177
180
183
186
189
192
195
195
195
116
119
122
125
128
131
134
137
140
143
146
149
152
155
158
161
164
167
170
173
176
179
182
185
188
191...

result:

ok Perfect :) Use 3631 operations

Test #155:

score: 5
Accepted
time: 2ms
memory: 3500kb

input:

8 200 6
49 76 125 124 10 48 77 108 79 113 127 84 21 22 30 33 129 164 73 177 70 82 148 5 160 133 63 140 154 158 175 165 182 97 197 149 99 20 72 26 162 94 101 78 52 132 109 62 24 169 142 11 136 186 2 58 130 114 193 4 53 199 111 14 187 75 155 98 194 45 170 112 92 29 34 32 135 69 17 89 191 174 91 166 12...

output:

2486
106
111
116
121
126
131
136
141
146
151
156
161
166
171
176
181
186
191
194
193
194
61
66
71
76
81
86
91
96
101
106
111
116
121
126
131
136
141
146
151
156
161
166
171
176
181
186
191
192
193
128
133
138
143
148
153
158
163
168
173
178
183
188
190
192
34
39
44
49
54
59
64
69
74
79
84
89
94
99
1...

result:

ok Perfect :) Use 2486 operations

Subtask #9:

score: 5
Accepted

Test #156:

score: 5
Accepted
time: 3ms
memory: 3780kb

input:

9 1000 5
211 100 879 298 625 856 443 312 159 430 391 546 577 436 137 720 561 290 847 592 187 120 953 60 979 94 583 700 623 80 627 732 675 24 987 340 221 974 1 816 881 280 495 432 853 212 117 986 667 148 127 664 481 524 725 82 543 906 819 394 581 950 91 866 573 496 251 392 775 730 273 784 511 90 359 ...

output:

63633
461
465
469
473
477
481
485
489
493
497
501
505
509
513
517
521
525
529
533
537
541
545
549
553
557
561
565
569
573
577
581
585
589
593
597
601
605
609
613
617
621
625
629
633
637
641
645
649
653
657
661
665
669
673
677
681
685
689
693
697
701
705
709
713
717
721
725
729
733
737
741
745
749
75...

result:

ok Perfect :) Use 63633 operations

Test #157:

score: 5
Accepted
time: 3ms
memory: 3552kb

input:

9 1000 5
991 372 741 582 45 614 789 632 177 444 907 842 385 240 835 992 461 722 465 82 39 338 881 182 647 656 553 24 949 642 971 160 229 322 69 488 367 768 533 348 191 878 965 398 181 132 303 216 171 204 5 748 867 188 557 858 993 784 233 866 63 888 605 184 145 482 903 94 173 168 175 248 875 610 527 ...

output:

62560
725
729
733
737
741
745
749
753
757
761
765
769
773
777
781
785
789
793
797
801
805
809
813
817
821
825
829
833
837
841
845
849
853
857
861
865
869
873
877
881
885
889
893
897
901
905
909
913
917
921
925
929
933
937
941
945
949
953
957
961
965
969
973
977
981
985
989
993
994
995
510
514
518
52...

result:

ok Perfect :) Use 62560 operations

Test #158:

score: 5
Accepted
time: 6ms
memory: 3704kb

input:

9 1000 5
225 426 517 772 477 142 703 312 71 710 371 854 891 776 483 388 929 148 19 922 621 564 629 810 863 442 449 652 819 782 335 762 171 868 789 154 257 770 695 292 821 910 237 146 269 872 395 56 251 208 813 248 417 546 505 594 711 566 41 72 435 308 101 876 295 466 363 434 611 640 685 240 759 898 ...

output:

63189
231
235
239
243
247
251
255
259
263
267
271
275
279
283
287
291
295
299
303
307
311
315
319
323
327
331
335
339
343
347
351
355
359
363
367
371
375
379
383
387
391
395
399
403
407
411
415
419
423
427
431
435
439
443
447
451
455
459
463
467
471
475
479
483
487
491
495
499
503
507
511
515
519
52...

result:

ok Perfect :) Use 63189 operations

Test #159:

score: 5
Accepted
time: 3ms
memory: 3868kb

input:

9 1000 5
185 540 819 982 831 622 777 776 311 978 641 1000 857 16 47 808 49 122 435 826 395 560 799 538 163 384 281 80 605 686 467 460 195 242 513 162 769 224 615 930 999 548 719 642 455 128 439 964 563 248 287 14 581 716 821 250 283 906 265 878 551 346 867 90 579 472 291 342 765 512 471 814 633 476 ...

output:

-1

result:

ok No solutions

Test #160:

score: 5
Accepted
time: 2ms
memory: 3448kb

input:

9 5 5
5 4 3 2 1

output:

1
0

result:

ok Perfect :) Use 1 operations

Test #161:

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

input:

9 5 5
1 5 4 2 3

output:

-1

result:

ok No solutions

Test #162:

score: 5
Accepted
time: 2ms
memory: 3564kb

input:

9 5 5
2 3 4 5 1

output:

-1

result:

ok No solutions

Test #163:

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

input:

9 6 5
1 2 3 4 5 6

output:

0

result:

ok Perfect :) Use 0 operations

Test #164:

score: 5
Accepted
time: 2ms
memory: 3472kb

input:

9 6 5
3 4 5 2 1 6

output:

-1

result:

ok No solutions

Test #165:

score: 5
Accepted
time: 1ms
memory: 3456kb

input:

9 6 5
6 5 4 3 2 1

output:

-1

result:

ok No solutions

Test #166:

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

input:

9 7 5
3 2 5 4 1 6 7

output:

10
0
1
2
1
1
0
2
1
1
0

result:

ok Perfect :) Use 10 operations

Test #167:

score: 5
Accepted
time: 2ms
memory: 3516kb

input:

9 7 5
7 6 3 2 5 4 1

output:

-1

result:

ok No solutions

Subtask #10:

score: 5
Accepted

Test #168:

score: 5
Accepted
time: 8ms
memory: 3964kb

input:

10 1000 4
758 267 63 485 736 202 48 317 86 106 157 637 213 476 900 811 830 915 333 457 665 423 51 881 837 615 228 201 151 69 87 753 312 999 810 483 409 630 790 497 120 838 969 170 3 271 316 365 831 598 801 199 931 200 768 16 357 874 869 481 771 262 508 850 146 67 136 674 670 649 845 621 109 602 150 ...

output:

85327
438
441
444
447
450
453
456
459
462
465
468
471
474
477
480
483
486
489
492
495
498
501
504
507
510
513
516
519
522
525
528
531
534
537
540
543
546
549
552
555
558
561
564
567
570
573
576
579
582
585
588
591
594
597
600
603
606
609
612
615
618
621
624
627
630
633
636
639
642
645
648
651
654
65...

result:

ok Perfect :) Use 85327 operations

Test #169:

score: 5
Accepted
time: 4ms
memory: 3908kb

input:

10 1000 4
326 290 647 848 941 832 911 134 198 884 970 805 644 391 564 317 193 244 217 933 257 826 279 860 405 496 112 950 498 436 547 185 866 144 294 786 164 653 419 711 956 215 565 534 418 481 910 392 629 266 70 56 395 155 342 656 795 879 480 682 523 570 278 8 259 158 397 808 367 937 180 555 91 163...

output:

82573
614
617
620
623
626
629
632
635
638
641
644
647
650
653
656
659
662
665
668
671
674
677
680
683
686
689
692
695
698
701
704
707
710
713
716
719
722
725
728
731
734
737
740
743
746
749
752
755
758
761
764
767
770
773
776
779
782
785
788
791
794
797
800
803
806
809
812
815
818
821
824
827
830
83...

result:

ok Perfect :) Use 82573 operations

Test #170:

score: 5
Accepted
time: 4ms
memory: 3852kb

input:

10 1000 4
301 482 326 645 714 415 956 715 708 128 233 410 586 17 964 611 436 684 860 644 235 159 259 262 899 632 929 652 542 780 636 664 716 176 36 720 173 990 653 690 167 371 260 588 775 821 560 211 375 399 138 203 157 312 754 983 268 152 886 939 299 387 32 822 234 140 304 95 557 448 335 42 187 153...

output:

85074
761
764
767
770
773
776
779
782
785
788
791
794
797
800
803
806
809
812
815
818
821
824
827
830
833
836
839
842
845
848
851
854
857
860
863
866
869
872
875
878
881
884
887
890
893
896
899
902
905
908
911
914
917
920
923
926
929
932
935
938
941
944
947
950
953
956
959
962
965
968
971
974
977
98...

result:

ok Perfect :) Use 85074 operations

Test #171:

score: 5
Accepted
time: 3ms
memory: 3824kb

input:

10 1000 4
522 507 45 981 381 774 205 675 124 86 951 496 874 77 648 382 73 977 198 435 742 352 884 519 739 427 634 249 391 601 252 700 615 173 673 359 948 339 513 204 116 676 518 81 72 353 971 866 279 516 414 902 377 878 726 489 738 139 184 935 786 358 821 921 8 931 152 422 21 708 603 988 668 350 298...

output:

-1

result:

ok No solutions

Test #172:

score: 5
Accepted
time: 1ms
memory: 3448kb

input:

10 4 4
1 2 3 4

output:

0

result:

ok Perfect :) Use 0 operations

Test #173:

score: 5
Accepted
time: 2ms
memory: 3612kb

input:

10 4 4
2 1 4 3

output:

-1

result:

ok No solutions

Test #174:

score: 5
Accepted
time: 2ms
memory: 3584kb

input:

10 5 4
2 1 5 4 3

output:

3
0
1
0

result:

ok Perfect :) Use 3 operations

Test #175:

score: 5
Accepted
time: 2ms
memory: 3512kb

input:

10 5 4
5 4 1 3 2

output:

-1

result:

ok No solutions

Subtask #11:

score: 5
Accepted

Test #176:

score: 5
Accepted
time: 4ms
memory: 3784kb

input:

11 1000 7
975 294 573 546 575 370 471 988 77 438 155 162 877 176 441 260 189 178 381 936 495 106 405 854 739 674 395 332 627 628 605 1000 1 422 485 594 879 882 849 620 265 424 55 500 149 378 47 708 137 410 775 44 283 112 823 70 499 64 397 606 793 190 753 752 545 580 651 206 963 730 815 968 263 698 6...

output:

43074
31
37
43
49
55
61
67
73
79
85
91
97
103
109
115
121
127
133
139
145
151
157
163
169
175
181
187
193
199
205
211
217
223
229
235
241
247
253
259
265
271
277
283
289
295
301
307
313
319
325
331
337
343
349
355
361
367
373
379
385
391
397
403
409
415
421
427
433
439
445
451
457
463
469
475
481
48...

result:

ok Perfect :) Use 43074 operations

Test #177:

score: 5
Accepted
time: 5ms
memory: 3620kb

input:

11 1000 7
179 376 839 760 97 952 973 600 267 298 175 766 773 236 607 920 75 118 409 416 387 538 321 450 65 554 199 212 511 90 393 246 259 620 311 392 835 132 939 70 763 988 203 638 141 758 55 686 589 414 731 372 355 358 509 426 557 996 517 182 181 460 933 586 665 442 671 488 627 452 367 844 125 328 ...

output:

42837
83
89
95
101
107
113
119
125
131
137
143
149
155
161
167
173
179
185
191
197
203
209
215
221
227
233
239
245
251
257
263
269
275
281
287
293
299
305
311
317
323
329
335
341
347
353
359
365
371
377
383
389
395
401
407
413
419
425
431
437
443
449
455
461
467
473
479
485
491
497
503
509
515
521
5...

result:

ok Perfect :) Use 42837 operations

Test #178:

score: 5
Accepted
time: 6ms
memory: 3632kb

input:

11 1000 7
263 450 239 844 467 274 151 150 539 796 575 858 895 766 129 784 797 546 61 768 219 104 15 434 563 676 209 634 951 976 167 222 927 252 625 112 581 780 627 406 863 620 41 608 203 988 333 354 453 220 847 126 749 30 591 978 299 860 77 928 127 740 311 754 541 374 385 18 923 158 7 552 335 562 69...

output:

42240
115
121
127
133
139
145
151
157
163
169
175
181
187
193
199
205
211
217
223
229
235
241
247
253
259
265
271
277
283
289
295
301
307
313
319
325
331
337
343
349
355
361
367
373
379
385
391
397
403
409
415
421
427
433
439
445
451
457
463
469
475
481
487
493
499
505
511
517
523
529
535
541
547
55...

result:

ok Perfect :) Use 42240 operations

Test #179:

score: 5
Accepted
time: 2ms
memory: 3580kb

input:

11 7 7
1 2 3 4 5 6 7

output:

0

result:

ok Perfect :) Use 0 operations

Test #180:

score: 5
Accepted
time: 2ms
memory: 3636kb

input:

11 7 7
1 7 5 4 2 6 3

output:

-1

result:

ok No solutions

Test #181:

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

input:

11 7 7
2 3 4 5 6 7 1

output:

-1

result:

ok No solutions

Test #182:

score: 5
Accepted
time: 2ms
memory: 3636kb

input:

11 8 7
7 8 1 2 3 4 5 6

output:

6
0
1
0
1
0
1

result:

ok Perfect :) Use 6 operations

Test #183:

score: 5
Accepted
time: 2ms
memory: 3448kb

input:

11 8 7
8 7 6 5 4 3 2 1

output:

-1

result:

ok No solutions

Test #184:

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

input:

11 9 7
7 2 1 4 5 6 3 8 9

output:

20
1
0
1
2
1
0
1
0
1
0
2
1
2
1
1
0
1
0
1
0

result:

ok Perfect :) Use 20 operations

Test #185:

score: 5
Accepted
time: 2ms
memory: 3608kb

input:

11 9 7
3 6 5 4 1 2 9 8 7

output:

-1

result:

ok No solutions

Test #186:

score: 5
Accepted
time: 2ms
memory: 3448kb

input:

11 9 7
1 2 9 8 7 6 3 4 5

output:

-1

result:

ok No solutions

Subtask #12:

score: 5
Accepted

Test #187:

score: 5
Accepted
time: 6ms
memory: 3684kb

input:

12 1000 6
416 514 385 469 20 211 283 558 116 425 351 927 713 189 649 827 54 441 327 759 273 466 971 829 108 738 200 21 557 577 266 541 507 115 480 646 673 179 820 430 84 458 249 869 676 127 482 80 606 545 639 919 974 826 718 783 741 775 549 693 202 477 291 528 48 366 137 483 95 350 709 966 55 312 62...

output:

51749
750
755
760
765
770
775
780
785
790
795
800
805
810
815
820
825
830
835
840
845
850
855
860
865
870
875
880
885
890
895
900
905
910
915
920
925
930
935
940
945
950
955
960
965
970
975
980
985
990
992
994
384
389
394
399
404
409
414
419
424
429
434
439
444
449
454
459
464
469
474
479
484
489
49...

result:

ok Perfect :) Use 51749 operations

Test #188:

score: 5
Accepted
time: 6ms
memory: 3632kb

input:

12 1000 6
734 154 614 856 690 198 413 666 220 327 148 920 553 585 757 76 923 789 365 901 622 228 290 202 471 990 718 877 598 579 644 507 552 941 694 917 714 781 752 112 187 545 616 586 92 85 30 99 813 4 372 440 653 277 539 207 760 584 115 637 822 692 688 919 98 709 563 825 143 73 809 863 939 516 84 ...

output:

50546
732
737
742
747
752
757
762
767
772
777
782
787
792
797
802
807
812
817
822
827
832
837
842
847
852
857
862
867
872
877
882
887
892
897
902
907
912
917
922
927
932
937
942
947
952
957
962
967
972
977
982
987
992
993
994
264
269
274
279
284
289
294
299
304
309
314
319
324
329
334
339
344
349
35...

result:

ok Perfect :) Use 50546 operations

Test #189:

score: 5
Accepted
time: 6ms
memory: 3660kb

input:

12 1000 6
426 451 150 843 860 130 729 178 669 279 458 306 620 198 795 955 549 937 31 650 469 464 770 651 632 4 309 247 367 151 143 259 529 177 944 644 226 498 483 423 515 390 865 850 358 264 437 420 386 879 919 723 667 411 856 302 435 343 193 452 11 739 161 338 698 783 637 675 106 965 55 666 305 821...

output:

53113
604
609
614
619
624
629
634
639
644
649
654
659
664
669
674
679
684
689
694
699
704
709
714
719
724
729
734
739
744
749
754
759
764
769
774
779
784
789
794
799
804
809
814
819
824
829
834
839
844
849
854
859
864
869
874
879
884
889
894
899
904
909
914
919
924
929
934
939
944
949
954
959
964
96...

result:

ok Perfect :) Use 53113 operations

Test #190:

score: 5
Accepted
time: 2ms
memory: 3596kb

input:

12 1000 8
916 106 622 283 77 349 76 65 701 14 634 16 659 71 567 371 367 417 857 83 629 161 932 882 657 524 931 997 995 970 22 893 449 59 1000 234 291 752 725 357 420 262 191 458 503 869 552 419 463 81 590 672 744 573 15 868 218 422 435 442 176 624 545 326 913 816 751 612 688 181 687 397 302 241 471 ...

output:

38422
34
41
48
55
62
69
76
83
90
97
104
111
118
125
132
139
146
153
160
167
174
181
188
195
202
209
216
223
230
237
244
251
258
265
272
279
286
293
300
307
314
321
328
335
342
349
356
363
370
377
384
391
398
405
412
419
426
433
440
447
454
461
468
475
482
489
496
503
510
517
524
531
538
545
552
559
...

result:

ok Perfect :) Use 38422 operations

Test #191:

score: 5
Accepted
time: 5ms
memory: 3672kb

input:

12 1000 8
842 480 888 935 207 901 669 311 841 401 223 192 971 569 974 215 235 353 33 758 609 161 188 655 495 885 153 983 571 409 403 825 39 283 894 87 934 640 709 304 313 258 159 976 183 7 603 838 742 432 565 367 689 543 262 4 793 895 796 992 826 998 173 531 456 93 898 662 127 653 116 729 402 479 63...

output:

38621
910
917
924
931
938
945
952
959
966
973
980
987
992
991
992
508
515
522
529
536
543
550
557
564
571
578
585
592
599
606
613
620
627
634
641
648
655
662
669
676
683
690
697
704
711
718
725
732
739
746
753
760
767
774
781
788
795
802
809
816
823
830
837
844
851
858
865
872
879
886
893
900
907
91...

result:

ok Perfect :) Use 38621 operations

Test #192:

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

input:

12 1000 8
351 377 405 356 716 720 634 526 665 700 908 999 538 207 549 936 896 288 102 311 739 27 474 550 63 632 913 162 448 950 360 241 193 561 208 942 229 673 198 308 582 461 399 143 839 838 96 158 342 837 614 46 189 476 275 643 323 728 762 455 258 491 359 519 857 99 927 132 103 510 61 684 251 797 ...

output:

38250
563
570
577
584
591
598
605
612
619
626
633
640
647
654
661
668
675
682
689
696
703
710
717
724
731
738
745
752
759
766
773
780
787
794
801
808
815
822
829
836
843
850
857
864
871
878
885
892
899
906
913
920
927
934
941
948
955
962
969
976
983
990
991
992
11
18
25
32
39
46
53
60
67
74
81
88
95...

result:

ok Perfect :) Use 38250 operations

Test #193:

score: 5
Accepted
time: 2ms
memory: 3764kb

input:

12 1000 8
803 115 31 95 772 296 615 417 636 380 712 255 238 470 257 552 874 212 377 679 909 520 484 30 513 651 383 414 546 34 532 983 865 645 861 888 80 830 607 824 821 200 521 141 381 67 114 91 516 130 625 476 419 630 860 641 896 397 775 757 613 314 624 317 43 20 391 109 895 911 56 469 64 272 171 1...

output:

-1

result:

ok No solutions

Test #194:

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

input:

12 7 6
1 7 6 5 4 3 2

output:

13
0
1
0
1
0
1
0
1
0
1
0
1
0

result:

ok Perfect :) Use 13 operations

Test #195:

score: 5
Accepted
time: 2ms
memory: 3520kb

input:

12 7 6
4 5 7 6 3 2 1

output:

-1

result:

ok No solutions

Test #196:

score: 5
Accepted
time: 2ms
memory: 3616kb

input:

12 8 8
1 2 3 4 5 6 7 8

output:

0

result:

ok Perfect :) Use 0 operations

Test #197:

score: 5
Accepted
time: 2ms
memory: 3580kb

input:

12 8 8
1 3 8 2 7 6 5 4

output:

-1

result:

ok No solutions

Test #198:

score: 5
Accepted
time: 2ms
memory: 3504kb

input:

12 8 8
6 7 8 1 2 3 4 5

output:

-1

result:

ok No solutions

Test #199:

score: 5
Accepted
time: 2ms
memory: 3560kb

input:

12 9 8
2 1 9 8 7 6 5 4 3

output:

7
0
1
0
1
0
1
0

result:

ok Perfect :) Use 7 operations

Test #200:

score: 5
Accepted
time: 1ms
memory: 3392kb

input:

12 9 8
2 6 4 8 3 7 9 5 1

output:

-1

result:

ok No solutions

Subtask #13:

score: 5
Accepted

Test #201:

score: 5
Accepted
time: 2ms
memory: 3564kb

input:

13 60 59
53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 60 59 58 57 56 55 54

output:

7
0
1
0
1
0
1
0

result:

ok Perfect :) Use 7 operations

Test #202:

score: 5
Accepted
time: 2ms
memory: 3636kb

input:

13 60 59
59 42 3 20 41 40 51 30 31 38 33 32 43 18 53 6 37 60 19 8 29 10 45 50 21 34 5 44 7 54 55 52 15 22 57 4 17 26 23 16 11 36 39 12 1 28 9 46 47 24 13 56 25 48 35 14 27 58 49 2

output:

-1

result:

ok No solutions

Test #203:

score: 5
Accepted
time: 2ms
memory: 3456kb

input:

13 60 59
60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

-1

result:

ok No solutions

Test #204:

score: 5
Accepted
time: 2ms
memory: 3452kb

input:

13 60 59
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

output:

-1

result:

ok No solutions

Test #205:

score: 5
Accepted
time: 2ms
memory: 3464kb

input:

13 59 59
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

output:

0

result:

ok Perfect :) Use 0 operations

Test #206:

score: 5
Accepted
time: 1ms
memory: 3560kb

input:

13 59 59
36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37

output:

-1

result:

ok No solutions

Test #207:

score: 5
Accepted
time: 2ms
memory: 3532kb

input:

13 61 59
1 60 41 58 57 56 61 54 13 52 53 50 37 48 25 46 47 44 15 42 19 40 5 38 3 36 59 34 31 32 29 30 55 28 51 26 39 24 43 22 45 20 9 18 23 16 17 14 7 12 21 10 11 8 35 6 33 4 49 2 27

output:

625
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
2
...

result:

ok Perfect :) Use 625 operations

Test #208:

score: 5
Accepted
time: 2ms
memory: 3596kb

input:

13 61 59
3 28 9 26 43 24 29 22 19 20 15 18 1 16 21 14 35 12 57 10 41 8 7 6 5 4 61 2 37 60 39 58 51 56 11 54 49 52 33 50 45 48 53 46 23 44 47 42 59 40 27 38 31 36 13 34 25 32 55 30 17

output:

-1

result:

ok No solutions

Test #209:

score: 5
Accepted
time: 3ms
memory: 3544kb

input:

13 1000 59
627 790 421 90 785 774 271 216 401 846 241 114 499 544 809 68 929 586 611 740 909 164 813 312 557 900 945 24 957 600 803 858 273 616 899 38 999 982 863 938 203 138 519 188 657 814 919 934 609 340 763 688 311 378 667 294 851 428 339 436 671 70 821 754 943 908 947 856 79 86 599 994 815 42 9...

output:

7565
869
927
934
941
36
94
152
210
268
326
384
442
500
558
616
674
732
790
848
906
923
940
591
649
707
765
823
881
939
939
939
896
917
938
733
791
849
907
922
937
606
664
722
780
838
896
916
936
59
117
175
233
291
349
407
465
523
581
639
697
755
813
871
929
932
935
758
816
874
932
933
934
235
293
35...

result:

ok Perfect :) Use 7565 operations

Test #210:

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

input:

13 1000 59
293 794 791 384 249 494 703 534 411 58 733 142 727 904 691 56 139 820 337 156 825 284 547 452 915 390 189 288 403 116 743 66 179 50 625 728 513 730 379 144 509 812 623 938 927 322 257 238 23 970 991 654 219 126 767 804 327 150 81 984 335 578 359 148 849 410 471 140 77 588 953 692 689 910 ...

output:

7504
193
251
309
367
425
483
541
599
657
715
773
831
889
915
941
444
502
560
618
676
734
792
850
908
924
940
657
715
773
831
889
914
939
362
420
478
536
594
652
710
768
826
884
911
938
623
681
739
797
855
913
925
937
462
520
578
636
694
752
810
868
926
931
936
865
923
929
935
122
180
238
296
354
412...

result:

ok Perfect :) Use 7504 operations

Test #211:

score: 5
Accepted
time: 2ms
memory: 3532kb

input:

13 57 55
35 34 49 36 19 38 25 40 3 42 57 44 1 46 33 48 27 50 9 52 17 54 41 56 31 2 13 4 53 6 51 8 23 10 43 12 7 14 5 16 29 18 55 20 39 22 11 24 45 26 21 28 37 30 15 32 47

output:

612
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
2
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
...

result:

ok Perfect :) Use 612 operations

Test #212:

score: 5
Accepted
time: 2ms
memory: 3596kb

input:

13 57 55
37 50 5 24 13 48 1 34 25 40 43 46 29 16 33 2 45 12 55 20 53 56 47 10 15 52 7 18 41 6 49 14 11 8 9 36 17 38 51 30 3 4 35 28 23 54 57 44 21 42 19 26 31 22 27 32 39

output:

-1

result:

ok No solutions

Test #213:

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

input:

13 57 55
3 30 39 32 23 34 53 36 45 38 35 40 21 42 33 44 43 46 11 48 19 50 49 52 15 54 17 56 57 2 7 4 51 6 9 8 25 10 29 12 41 14 31 16 27 18 5 20 47 22 55 24 1 26 37 28 13

output:

-1

result:

ok No solutions

Test #214:

score: 5
Accepted
time: 3ms
memory: 3464kb

input:

13 1000 55
241 104 795 750 991 158 133 410 227 580 425 564 683 608 291 12 29 470 551 308 463 236 511 592 353 542 601 414 777 700 663 412 527 986 83 128 785 748 15 74 791 166 595 668 887 96 859 594 33 48 109 570 393 924 927 518 599 456 249 98 377 34 417 280 69 110 855 526 179 130 123 670 625 656 341 ...

output:

7188
479
533
587
641
695
749
803
857
911
928
945
144
198
252
306
360
414
468
522
576
630
684
738
792
846
900
922
944
283
337
391
445
499
553
607
661
715
769
823
877
931
937
943
919
942
177
231
285
339
393
447
501
555
609
663
717
771
825
879
933
937
941
238
292
346
400
454
508
562
616
670
724
778
832...

result:

ok Perfect :) Use 7188 operations

Test #215:

score: 5
Accepted
time: 2ms
memory: 3456kb

input:

13 1000 55
522 206 866 768 985 887 927 582 430 556 204 917 899 271 891 790 588 113 520 940 18 241 310 300 358 842 884 48 946 56 623 992 180 379 599 58 457 959 988 572 869 654 507 540 61 845 583 63 918 93 386 124 247 441 9 592 490 867 173 351 528 655 576 527 530 279 936 764 584 967 211 784 349 265 24...

output:

-1

result:

ok No solutions

Test #216:

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

input:

13 55 53
43 48 3 50 11 52 39 54 19 2 27 4 15 6 23 8 13 10 41 12 55 14 45 16 25 18 47 20 7 22 5 24 35 26 33 28 21 30 17 32 1 34 51 36 31 38 53 40 9 42 49 44 29 46 37

output:

714
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
...

result:

ok Perfect :) Use 714 operations

Test #217:

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

input:

13 55 53
25 20 13 18 37 16 21 14 9 12 35 10 51 8 27 6 17 4 3 2 15 54 43 52 33 50 47 48 23 46 7 44 19 42 45 40 41 38 49 36 53 34 39 32 55 30 31 28 1 26 5 24 11 22 29

output:

-1

result:

ok No solutions

Test #218:

score: 5
Accepted
time: 3ms
memory: 3580kb

input:

13 1000 53
425 780 879 494 89 688 657 72 937 792 459 696 907 844 775 896 689 422 181 740 529 148 509 290 541 768 715 58 583 482 35 366 963 476 611 912 563 160 427 782 423 560 303 362 5 128 383 832 699 742 909 304 653 378 945 898 31 884 681 532 235 538 75 316 327 826 101 282 923 436 691 930 961 142 6...

output:

7479
887
939
943
947
939
946
231
283
335
387
439
491
543
595
647
699
751
803
855
907
926
945
286
338
390
442
494
546
598
650
702
754
806
858
910
927
944
815
867
919
931
943
502
554
606
658
710
762
814
866
918
930
942
928
941
925
940
295
347
399
451
503
555
607
659
711
763
815
867
919
929
939
252
304...

result:

ok Perfect :) Use 7479 operations

Test #219:

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

input:

13 1000 53
451 396 195 412 41 962 205 190 345 666 691 312 509 754 599 42 277 680 585 284 705 702 773 426 153 508 283 682 77 814 267 90 701 974 261 846 145 496 909 994 443 188 851 216 33 982 747 908 849 978 251 522 295 228 543 660 723 344 789 852 597 550 177 210 865 740 465 790 427 248 645 250 149 86...

output:

-1

result:

ok No solutions

Test #220:

score: 5
Accepted
time: 2ms
memory: 3460kb

input:

13 45 43
23 42 15 40 35 38 21 36 33 34 7 32 27 30 13 28 43 26 9 24 19 22 39 20 41 18 37 16 5 14 11 12 31 10 29 8 25 6 1 4 3 2 17 44 45

output:

351
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
2
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
1
0
1
2
1
0
1
...

result:

ok Perfect :) Use 351 operations

Test #221:

score: 5
Accepted
time: 2ms
memory: 3528kb

input:

13 45 43
5 24 11 26 7 28 19 30 9 32 3 34 23 36 43 38 35 40 45 42 27 44 1 2 25 4 37 6 21 8 17 10 33 12 29 14 39 16 31 18 41 20 13 22 15

output:

-1

result:

ok No solutions

Test #222:

score: 5
Accepted
time: 3ms
memory: 3600kb

input:

13 1000 43
81 316 875 938 335 400 437 728 827 832 399 436 227 120 411 584 61 550 319 644 129 914 951 704 553 458 131 872 403 712 91 654 173 186 587 576 151 394 331 344 45 232 863 958 831 754 479 870 429 74 17 798 469 196 857 154 163 454 185 986 653 434 741 238 377 176 165 254 807 930 161 212 101 96 ...

output:

8031
897
939
948
957
238
280
322
364
406
448
490
532
574
616
658
700
742
784
826
868
910
952
954
956
869
911
953
954
955
500
542
584
626
668
710
752
794
836
878
920
937
954
367
409
451
493
535
577
619
661
703
745
787
829
871
913
933
953
224
266
308
350
392
434
476
518
560
602
644
686
728
770
812
854...

result:

ok Perfect :) Use 8031 operations

Test #223:

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

input:

13 43 41
29 42 1 40 41 38 27 36 11 34 21 32 17 30 7 28 39 26 13 24 43 22 23 20 35 18 3 16 19 14 25 12 31 10 33 8 15 6 37 4 9 2 5

output:

403
1
0
1
2
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
0
0
1
0
1
0
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

result:

ok Perfect :) Use 403 operations

Test #224:

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

input:

13 43 41
39 30 11 32 13 34 29 36 15 38 7 40 1 42 37 2 3 4 31 6 9 8 27 10 33 12 17 14 23 16 19 18 41 20 21 22 5 24 43 26 35 28 25

output:

-1

result:

ok No solutions

Test #225:

score: 5
Accepted
time: 3ms
memory: 3620kb

input:

13 1000 41
971 654 63 930 351 590 79 358 753 188 905 696 599 376 101 794 621 848 871 480 991 414 207 672 349 580 791 270 359 852 397 362 369 24 979 348 299 700 467 424 501 64 391 438 431 34 505 338 319 638 671 496 985 334 499 668 925 632 323 164 831 450 707 816 651 674 595 398 217 380 747 482 785 33...

output:

8418
283
323
363
403
443
483
523
563
603
643
683
723
763
803
843
883
923
941
959
696
736
776
816
856
896
936
947
958
309
349
389
429
469
509
549
589
629
669
709
749
789
829
869
909
949
953
957
258
298
338
378
418
458
498
538
578
618
658
698
738
778
818
858
898
938
947
956
277
317
357
397
437
477
517...

result:

ok Perfect :) Use 8418 operations

Test #226:

score: 5
Accepted
time: 3ms
memory: 3636kb

input:

13 1000 41
829 74 119 708 453 536 39 488 447 832 611 766 369 334 155 882 725 970 739 370 715 34 477 786 159 668 851 442 375 868 927 582 591 516 435 816 929 682 949 14 789 960 195 794 81 322 775 680 185 414 769 196 337 342 779 316 11 504 467 528 59 348 47 844 631 1000 873 514 881 314 103 150 19 52 18...

output:

8525
65
105
145
185
225
265
305
345
385
425
465
505
545
585
625
665
705
745
785
825
865
905
945
952
959
530
570
610
650
690
730
770
810
850
890
930
944
958
95
135
175
215
255
295
335
375
415
455
495
535
575
615
655
695
735
775
815
855
895
935
946
957
912
952
954
956
291
331
371
411
451
491
531
571
6...

result:

ok Perfect :) Use 8525 operations

Test #227:

score: 5
Accepted
time: 3ms
memory: 3612kb

input:

13 1000 41
941 54 399 530 335 792 79 658 863 40 955 816 753 894 277 452 131 240 83 606 191 626 965 450 477 880 771 62 715 30 647 136 797 6 969 222 241 364 819 376 281 642 601 618 961 448 631 380 583 182 623 630 629 294 391 822 787 140 329 532 807 510 367 390 901 280 687 682 991 196 541 242 49 244 48...

output:

8361
749
789
829
869
909
949
954
959
142
182
222
262
302
342
382
422
462
502
542
582
622
662
702
742
782
822
862
902
942
950
958
399
439
479
519
559
599
639
679
719
759
799
839
879
919
938
957
586
626
666
706
746
786
826
866
906
946
951
956
915
955
955
955
466
506
546
586
626
666
706
746
786
826
866...

result:

ok Perfect :) Use 8361 operations

Test #228:

score: 5
Accepted
time: 1ms
memory: 3516kb

input:

13 1000 41
477 316 957 122 121 650 27 890 33 272 423 620 341 704 69 566 413 638 133 836 733 142 681 170 11 264 109 718 945 994 507 16 175 8 745 894 61 872 655 956 289 518 439 732 303 814 395 222 463 526 585 348 41 520 249 652 247 448 385 568 583 658 465 210 689 106 415 656 9 796 705 386 59 470 795 7...

output:

-1

result:

ok No solutions

Test #229:

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

input:

13 1000 41
343 894 623 66 439 404 721 140 785 226 369 208 755 774 793 596 271 870 541 192 101 720 419 988 145 888 557 242 435 958 299 776 403 524 345 844 771 314 167 430 503 838 765 58 313 440 749 860 251 260 783 504 993 496 563 376 215 196 559 420 317 412 709 738 655 666 571 328 531 274 287 924 699...

output:

-1

result:

ok No solutions

Test #230:

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

input:

13 1000 41
343 264 767 142 657 496 841 648 377 732 133 436 69 578 497 280 355 498 93 670 599 158 845 478 399 752 295 790 591 948 691 366 991 302 1 150 31 686 393 32 907 922 423 18 91 816 407 850 225 738 211 390 755 714 293 92 977 506 969 848 959 454 899 552 35 268 193 728 137 962 67 148 285 78 825 3...

output:

-1

result:

ok No solutions

Subtask #14:

score: 5
Accepted

Test #231:

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

input:

14 60 60
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

output:

0

result:

ok Perfect :) Use 0 operations

Test #232:

score: 5
Accepted
time: 2ms
memory: 3456kb

input:

14 60 60
30 60 33 25 45 40 41 14 59 5 34 50 13 57 46 8 48 53 19 3 56 20 31 37 32 7 28 44 4 27 58 47 24 17 43 21 23 6 22 38 9 36 29 16 26 1 10 11 12 51 42 52 2 35 49 18 54 39 55 15

output:

-1

result:

ok No solutions

Test #233:

score: 5
Accepted
time: 2ms
memory: 3616kb

input:

14 60 60
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

output:

-1

result:

ok No solutions

Test #234:

score: 5
Accepted
time: 1ms
memory: 3636kb

input:

14 51 50
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 1 2 3 4 5 6 7 8 9 10 11

output:

62
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

result:

ok Perfect :) Use 62 operations

Test #235:

score: 5
Accepted
time: 2ms
memory: 3640kb

input:

14 51 50
36 50 35 4 24 38 16 42 26 12 19 44 7 27 39 10 1 5 3 18 25 20 14 33 17 51 43 11 31 2 22 34 13 23 41 37 6 45 32 47 15 28 8 40 21 48 49 9 29 46 30

output:

-1

result:

ok No solutions

Test #236:

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

input:

14 1000 40
783 688 933 732 144 245 668 115 364 678 148 794 8 177 728 420 371 932 686 184 292 964 600 322 851 96 617 816 707 586 248 434 409 951 736 878 801 610 655 185 698 882 632 38 961 929 145 557 111 826 679 923 441 508 760 135 827 888 568 392 917 898 429 881 190 76 21 706 298 995 459 391 841 393...

output:

10319
960
943
960
656
695
734
773
812
851
890
929
944
959
80
119
158
197
236
275
314
353
392
431
470
509
548
587
626
665
704
743
782
821
860
899
938
948
958
608
647
686
725
764
803
842
881
920
957
956
957
870
909
948
952
956
69
108
147
186
225
264
303
342
381
420
459
498
537
576
615
654
693
732
771
...

result:

ok Perfect :) Use 10319 operations

Test #237:

score: 5
Accepted
time: 3ms
memory: 3568kb

input:

14 1000 40
961 148 697 548 723 281 69 994 509 747 940 972 75 67 718 244 498 347 655 230 367 778 263 814 390 966 331 549 652 565 714 800 475 786 679 146 627 305 233 346 459 896 128 61 414 867 98 792 561 427 647 99 587 532 950 537 71 877 928 803 422 64 791 591 380 10 408 990 318 428 711 462 80 155 854...

output:

10320
941
960
287
326
365
404
443
482
521
560
599
638
677
716
755
794
833
872
911
950
959
944
959
768
807
846
885
924
941
958
655
694
733
772
811
850
889
928
957
952
957
475
514
553
592
631
670
709
748
787
826
865
904
943
956
943
956
905
944
955
941
955
7
46
85
124
163
202
241
280
319
358
397
436
47...

result:

ok Perfect :) Use 10320 operations

Test #238:

score: 5
Accepted
time: 3ms
memory: 3756kb

input:

14 1000 40
946 990 315 83 929 424 408 311 14 475 222 298 593 514 785 381 634 774 135 137 672 130 606 885 416 467 375 217 28 473 260 723 983 886 267 487 846 607 233 692 890 728 429 297 154 515 894 664 994 795 64 619 680 997 845 597 502 391 992 855 751 410 482 301 834 683 258 342 39 283 145 231 507 78...

output:

10181
330
369
408
447
486
525
564
603
642
681
720
759
798
837
876
915
954
957
960
142
181
220
259
298
337
376
415
454
493
532
571
610
649
688
727
766
805
844
883
922
959
958
959
396
435
474
513
552
591
630
669
708
747
786
825
864
903
942
950
958
53
92
131
170
209
248
287
326
365
404
443
482
521
560
...

result:

ok Perfect :) Use 10181 operations

Test #239:

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

input:

14 1000 40
913 244 275 607 284 817 824 214 353 141 625 802 881 697 155 420 37 192 995 623 733 171 188 949 667 763 572 265 478 140 95 870 43 925 145 696 213 477 78 102 957 229 314 655 601 172 699 466 598 739 707 113 785 742 227 20 895 223 389 216 6 337 600 720 276 196 272 780 132 212 683 703 334 520 ...

output:

-1

result:

ok No solutions

Test #240:

score: 5
Accepted
time: 3ms
memory: 3504kb

input:

14 1000 42
160 546 484 3 416 842 854 37 710 184 763 485 548 808 825 871 611 806 626 676 161 458 582 166 453 903 142 383 123 57 147 923 523 149 165 220 911 73 812 431 441 405 820 325 984 478 875 870 704 248 851 53 545 739 630 578 653 801 212 703 652 270 968 284 259 207 401 796 83 705 902 561 282 118 ...

output:

9986
442
483
524
565
606
647
688
729
770
811
852
893
934
946
958
693
734
775
816
857
898
939
948
957
956
938
956
807
848
889
930
955
947
955
568
609
650
691
732
773
814
855
896
937
954
942
954
944
953
937
953
189
230
271
312
353
394
435
476
517
558
599
640
681
722
763
804
845
886
927
952
944
952
131...

result:

ok Perfect :) Use 9986 operations

Test #241:

score: 5
Accepted
time: 2ms
memory: 3576kb

input:

14 1000 50
115 77 819 891 579 42 653 532 560 342 117 774 239 881 165 843 399 735 949 826 321 369 627 412 225 339 855 504 50 639 466 886 518 64 451 719 584 249 656 293 471 997 762 770 556 141 25 372 33 204 610 943 123 940 295 764 806 953 484 857 463 40 56 157 894 104 153 680 217 89 878 462 582 443 85...

output:

9908
211
260
309
358
407
456
505
554
603
652
701
750
799
848
897
946
948
950
537
586
635
684
733
782
831
880
929
939
949
902
925
948
41
90
139
188
237
286
335
384
433
482
531
580
629
678
727
776
825
874
923
935
947
470
519
568
617
666
715
764
813
862
911
946
939
946
96
145
194
243
292
341
390
439
48...

result:

ok Perfect :) Use 9908 operations

Test #242:

score: 5
Accepted
time: 1ms
memory: 3628kb

input:

14 1000 50
716 908 369 795 23 741 562 646 989 610 339 121 281 11 750 910 583 128 385 830 204 927 828 621 223 22 626 859 102 300 38 973 629 110 20 410 73 887 840 597 311 544 420 195 984 488 269 487 786 897 472 432 103 864 793 598 132 845 170 957 896 542 415 416 142 203 225 905 992 114 797 980 581 986...

output:

10117
85
134
183
232
281
330
379
428
477
526
575
624
673
722
771
820
869
918
934
950
444
493
542
591
640
689
738
787
836
885
934
949
932
949
704
753
802
851
900
924
948
253
302
351
400
449
498
547
596
645
694
743
792
841
890
939
943
947
319
368
417
466
515
564
613
662
711
760
809
858
907
946
941
946...

result:

ok Perfect :) Use 10117 operations

Test #243:

score: 5
Accepted
time: 3ms
memory: 3628kb

input:

14 1000 60
292 660 729 286 638 554 905 536 460 962 80 804 467 376 680 39 659 22 470 333 697 576 687 606 439 408 535 36 95 780 940 374 682 649 371 565 64 181 306 1 136 894 689 621 234 406 507 307 226 518 444 29 151 185 747 596 656 622 457 874 770 5 433 847 734 919 432 761 35 542 935 378 134 314 243 5...

output:

10106
933
940
914
940
284
343
402
461
520
579
638
697
756
815
874
933
936
939
717
776
835
894
916
938
579
638
697
756
815
874
933
935
937
916
926
936
759
818
877
906
935
417
476
535
594
653
712
771
830
889
934
927
934
368
427
486
545
604
663
722
781
840
899
916
933
891
932
923
932
666
725
784
843
90...

result:

ok Perfect :) Use 10106 operations

Test #244:

score: 5
Accepted
time: 3ms
memory: 3580kb

input:

14 1000 60
954 941 999 559 685 768 384 398 780 710 230 792 560 677 342 221 886 918 534 873 46 493 418 176 778 376 105 101 69 932 390 850 244 716 601 580 643 256 217 914 175 115 364 911 399 402 6 137 450 836 811 192 809 847 240 773 254 562 416 53 609 311 628 246 250 826 74 483 296 575 477 708 783 389...

output:

10191
452
511
570
629
688
747
806
865
924
932
940
2
61
120
179
238
297
356
415
474
533
592
651
710
769
828
887
913
939
533
592
651
710
769
828
887
938
934
938
334
393
452
511
570
629
688
747
806
865
924
937
914
937
786
845
904
920
936
253
312
371
430
489
548
607
666
725
784
843
902
935
922
935
178
2...

result:

ok Perfect :) Use 10191 operations

Test #245:

score: 5
Accepted
time: 2ms
memory: 3748kb

input:

14 1000 60
149 205 87 417 269 620 515 88 562 680 409 949 889 517 820 237 464 450 732 643 165 944 851 171 213 915 359 748 338 835 886 817 429 934 25 161 797 633 331 204 206 386 442 200 555 561 8 979 152 475 142 849 958 950 130 506 902 394 99 824 619 278 220 71 780 752 879 531 755 808 247 674 66 140 9...

output:

-1

result:

ok No solutions

Subtask #15:

score: 15
Accepted

Test #246:

score: 15
Accepted
time: 2ms
memory: 3532kb

input:

15 1000 999
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 ...

output:

418
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
...

result:

ok Perfect :) Use 418 operations

Test #247:

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

input:

15 1000 999
463 334 963 680 867 710 343 40 177 562 657 468 255 652 481 498 669 88 443 864 701 378 277 106 203 240 643 452 257 750 173 384 131 22 243 550 709 904 563 476 827 274 441 308 917 136 381 716 771 206 425 222 31 178 191 34 219 950 711 854 999 968 467 616 199 302 39 988 887 702 387 952 49 320...

output:

-1

result:

ok No solutions

Test #248:

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

input:

15 1000 999
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929...

output:

-1

result:

ok No solutions

Test #249:

score: 15
Accepted
time: 2ms
memory: 3664kb

input:

15 1000 999
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 ...

output:

-1

result:

ok No solutions

Test #250:

score: 15
Accepted
time: 2ms
memory: 3644kb

input:

15 999 999
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 1...

output:

0

result:

ok Perfect :) Use 0 operations

Test #251:

score: 15
Accepted
time: 2ms
memory: 3500kb

input:

15 999 999
761 760 759 758 757 756 755 754 753 752 751 750 749 748 747 746 745 744 743 742 741 740 739 738 737 736 735 734 733 732 731 730 729 728 727 726 725 724 723 722 721 720 719 718 717 716 715 714 713 712 711 710 709 708 707 706 705 704 703 702 701 700 699 698 697 696 695 694 693 692 691 690 6...

output:

-1

result:

ok No solutions

Test #252:

score: 15
Accepted
time: 34ms
memory: 4252kb

input:

15 999 997
73 92 445 94 575 96 907 98 137 100 849 102 507 104 191 106 905 108 951 110 927 112 609 114 647 116 595 118 249 120 99 122 305 124 145 126 277 128 51 130 845 132 409 134 319 136 161 138 577 140 993 142 141 144 459 146 245 148 695 150 751 152 219 154 523 156 175 158 639 160 55 162 593 164 2...

output:

203812
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1...

result:

ok Perfect :) Use 203812 operations

Test #253:

score: 15
Accepted
time: 20ms
memory: 4192kb

input:

15 999 997
641 328 961 42 73 622 411 812 129 234 679 356 465 822 521 330 471 758 319 56 665 912 847 14 17 960 853 700 401 676 623 268 351 340 495 710 453 978 749 706 897 868 933 320 517 40 609 560 657 192 259 550 711 28 767 442 19 986 381 512 303 224 915 836 419 968 879 368 203 920 315 680 261 326 9...

output:

-1

result:

ok No solutions

Test #254:

score: 15
Accepted
time: 22ms
memory: 4260kb

input:

15 999 997
725 946 881 944 417 942 81 940 379 938 601 936 789 934 981 932 433 930 647 928 593 926 973 924 575 922 483 920 945 918 439 916 859 914 895 912 465 910 337 908 13 906 965 904 825 902 197 900 813 898 799 896 205 894 669 892 541 890 855 888 333 886 987 884 621 882 115 880 369 878 303 876 371...

output:

-1

result:

ok No solutions

Test #255:

score: 15
Accepted
time: 42ms
memory: 5332kb

input:

15 1000 997
773 130 399 748 407 396 995 150 753 90 865 170 943 786 703 58 907 94 817 138 327 998 527 402 915 756 409 858 429 272 823 868 701 294 315 678 111 218 839 362 559 270 571 592 417 116 883 794 579 242 393 440 479 156 379 42 227 50 997 668 881 68 197 240 849 466 979 628 55 722 679 334 829 504...

output:

405216
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0...

result:

ok Perfect :) Use 405216 operations

Test #256:

score: 15
Accepted
time: 38ms
memory: 5232kb

input:

15 1000 997
643 98 303 698 191 798 7 676 301 582 785 860 437 80 735 424 51 4 351 334 751 100 651 506 531 792 393 436 563 240 625 872 857 56 449 762 971 632 605 16 817 542 203 638 713 556 463 900 19 620 965 136 903 308 851 888 585 536 33 118 315 952 573 368 331 876 899 696 461 322 697 30 963 870 515 ...

output:

400172
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1...

result:

ok Perfect :) Use 400172 operations

Test #257:

score: 15
Accepted
time: 41ms
memory: 5392kb

input:

15 1000 997
701 424 93 872 571 380 885 650 501 98 805 362 137 980 827 600 829 584 649 302 265 990 35 164 927 864 889 96 529 856 847 760 393 512 923 194 725 334 311 906 95 392 41 948 275 498 183 648 507 478 511 818 617 122 441 92 307 546 745 636 289 852 375 936 789 642 293 356 77 922 591 524 261 454 ...

output:

390972
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1...

result:

ok Perfect :) Use 390972 operations

Test #258:

score: 15
Accepted
time: 45ms
memory: 5444kb

input:

15 1000 997
389 810 131 216 461 50 281 20 391 294 451 918 821 980 497 550 365 712 655 648 707 444 521 944 91 474 93 198 119 54 227 124 643 748 447 540 991 338 861 592 421 646 623 12 291 192 909 116 195 366 429 850 981 86 609 402 877 168 199 840 113 908 849 604 759 526 957 798 275 984 349 558 681 160...

output:

386496
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
1...

result:

ok Perfect :) Use 386496 operations

Test #259:

score: 15
Accepted
time: 44ms
memory: 5236kb

input:

15 1000 997
137 356 571 52 167 912 197 830 943 742 757 114 411 508 843 34 865 904 383 400 901 98 981 842 105 478 265 176 657 412 819 818 733 352 377 364 637 528 701 802 175 290 367 986 997 954 545 76 855 476 339 650 851 360 863 482 85 212 45 432 281 782 871 74 461 112 251 614 691 964 967 958 609 740...

output:

391204
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0...

result:

ok Perfect :) Use 391204 operations

Test #260:

score: 15
Accepted
time: 2ms
memory: 3396kb

input:

15 1000 997
491 242 31 316 967 8 477 546 683 402 609 634 699 484 619 900 355 988 461 568 711 760 517 114 251 668 965 294 253 46 685 204 221 278 195 758 861 328 181 536 797 452 569 106 905 592 213 812 921 824 387 84 627 404 543 844 911 718 347 710 661 288 593 348 273 60 337 208 601 598 775 950 37 308...

output:

-1

result:

ok No solutions

Test #261:

score: 15
Accepted
time: 26ms
memory: 4296kb

input:

15 997 995
233 284 69 282 783 280 273 278 23 276 577 274 159 272 979 270 165 268 511 266 407 264 391 262 919 260 817 258 997 256 35 254 523 252 531 250 641 248 291 246 685 244 503 242 327 240 253 238 569 236 635 234 133 232 357 230 833 228 61 226 305 224 93 222 593 220 335 218 263 216 9 214 347 212 ...

output:

199541
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0...

result:

ok Perfect :) Use 199541 operations

Test #262:

score: 15
Accepted
time: 21ms
memory: 4208kb

input:

15 997 995
1 464 485 462 377 460 17 458 287 456 775 454 135 452 105 450 219 448 581 446 153 444 543 442 177 440 815 438 203 436 249 434 145 432 403 430 77 428 759 426 659 424 291 422 443 420 923 418 501 416 707 414 303 412 27 410 615 408 489 406 225 404 743 402 103 400 673 398 199 396 475 394 459 39...

output:

-1

result:

ok No solutions

Test #263:

score: 15
Accepted
time: 39ms
memory: 5288kb

input:

15 1000 995
279 700 335 72 365 746 541 642 23 940 3 930 661 122 699 594 367 66 693 104 81 576 303 812 75 348 835 292 407 890 193 106 711 934 941 78 221 826 977 566 411 730 575 1000 871 978 447 112 787 204 45 156 487 212 285 332 903 842 681 404 389 794 847 182 459 30 1 650 137 514 187 646 825 304 729...

output:

386362
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3...

result:

ok Perfect :) Use 386362 operations

Test #264:

score: 15
Accepted
time: 1ms
memory: 3400kb

input:

15 1000 995
675 43 115 667 626 301 187 816 152 543 771 252 390 408 154 405 382 322 219 247 435 383 75 440 524 334 296 402 392 517 814 496 236 215 593 898 809 479 841 466 233 819 145 59 173 856 199 827 297 54 443 800 289 470 947 680 436 356 74 185 812 548 225 678 451 822 715 945 619 769 870 336 465 5...

output:

-1

result:

ok No solutions

Test #265:

score: 15
Accepted
time: 32ms
memory: 4200kb

input:

15 995 993
79 632 211 634 427 636 869 638 675 640 233 642 579 644 281 646 301 648 265 650 783 652 147 654 31 656 61 658 825 660 307 662 613 664 443 666 171 668 555 670 607 672 525 674 291 676 65 678 413 680 197 682 381 684 881 686 565 688 761 690 51 692 491 694 591 696 127 698 447 700 45 702 917 704...

output:

197378
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1...

result:

ok Perfect :) Use 197378 operations

Test #266:

score: 15
Accepted
time: 21ms
memory: 4180kb

input:

15 995 993
803 500 671 502 911 504 349 506 429 508 229 510 419 512 243 514 537 516 381 518 439 520 597 522 345 524 51 526 571 528 427 530 761 532 225 534 499 536 87 538 121 540 183 542 709 544 487 546 227 548 719 550 629 552 827 554 903 556 557 558 809 560 205 562 551 564 701 566 285 568 759 570 649...

output:

-1

result:

ok No solutions

Test #267:

score: 15
Accepted
time: 41ms
memory: 5220kb

input:

15 1000 993
721 656 119 890 425 732 333 912 459 548 613 356 939 748 563 586 649 582 811 690 297 394 625 240 593 608 885 152 523 898 819 804 141 204 277 440 543 398 755 486 761 474 221 302 673 348 659 790 753 570 405 496 991 242 671 260 933 380 225 746 267 232 771 818 317 524 911 4 31 668 33 680 883 ...

output:

408926
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6
5
6...

result:

ok Perfect :) Use 408926 operations

Test #268:

score: 15
Accepted
time: 2ms
memory: 3472kb

input:

15 1000 993
637 480 117 186 933 990 897 166 751 660 833 868 225 408 271 918 693 22 647 310 703 492 697 138 573 510 937 630 195 646 355 618 577 754 779 378 459 6 627 132 821 156 543 472 851 574 525 506 909 662 125 600 307 592 769 788 87 206 947 454 925 612 679 728 985 384 61 532 967 814 915 174 331 3...

output:

-1

result:

ok No solutions

Test #269:

score: 15
Accepted
time: 2ms
memory: 3624kb

input:

15 1000 993
879 324 599 518 803 678 115 864 233 804 521 506 881 834 921 484 823 674 683 888 885 762 245 772 463 946 47 312 949 832 157 204 1 276 237 232 891 450 827 842 551 760 123 98 347 820 261 72 725 308 897 892 933 134 205 914 735 298 57 510 867 202 907 532 523 520 327 154 559 388 815 586 739 22...

output:

-1

result:

ok No solutions

Test #270:

score: 15
Accepted
time: 3ms
memory: 3636kb

input:

15 1000 993
641 754 93 588 107 638 127 426 557 196 871 926 767 120 341 782 155 822 117 136 363 410 883 582 189 630 791 286 567 924 311 382 659 614 739 968 687 904 485 930 949 872 537 766 415 618 819 374 205 612 303 686 927 880 411 442 653 988 31 492 777 510 323 344 69 918 265 326 371 300 67 412 869 ...

output:

-1

result:

ok No solutions

Test #271:

score: 15
Accepted
time: 33ms
memory: 4220kb

input:

15 993 991
551 320 907 318 339 316 85 314 399 312 619 310 801 308 249 306 747 304 789 302 643 300 937 298 615 296 881 294 737 292 689 290 221 288 17 286 203 284 699 282 701 280 435 278 783 276 497 274 195 272 601 270 733 268 505 266 31 264 119 262 451 260 213 258 55 256 53 254 357 252 667 250 271 24...

output:

209333
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1...

result:

ok Perfect :) Use 209333 operations

Test #272:

score: 15
Accepted
time: 17ms
memory: 4368kb

input:

15 993 991
787 16 483 14 463 12 191 10 991 8 603 6 217 4 299 2 415 992 311 990 531 988 215 986 993 984 527 982 685 980 197 978 327 976 159 974 399 972 17 970 329 968 359 966 151 964 369 962 659 960 583 958 189 956 735 954 639 952 523 950 561 948 587 946 567 944 481 942 763 940 281 938 47 936 91 934 ...

output:

-1

result:

ok No solutions

Test #273:

score: 15
Accepted
time: 40ms
memory: 5448kb

input:

15 1000 991
103 448 495 726 595 596 273 190 251 342 137 768 545 94 425 414 765 272 609 774 363 180 685 100 589 984 799 646 19 880 931 380 667 466 341 764 225 642 567 868 571 950 347 508 353 490 861 526 981 688 769 628 81 232 903 120 23 202 617 960 517 552 553 930 793 400 53 488 469 524 443 756 827 8...

output:

397173
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9...

result:

ok Perfect :) Use 397173 operations

Test #274:

score: 15
Accepted
time: 1ms
memory: 3640kb

input:

15 1000 1
267 942 413 612 243 436 343 10 701 914 97 80 29 390 975 740 199 996 209 348 177 184 837 44 829 670 671 74 953 552 535 84 427 460 589 336 479 138 95 276 277 794 647 108 261 926 105 344 695 760 949 420 459 218 461 36 883 812 545 944 505 332 487 50 583 268 677 932 663 312 163 394 69 122 565 2...

output:

-1

result:

ok No solutions

Test #275:

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

input:

15 1000 3
523 324 643 926 681 518 527 402 969 116 247 230 777 780 809 214 401 516 743 390 737 114 469 366 947 630 319 448 557 226 703 496 23 166 89 438 877 910 207 644 745 2 131 698 673 336 631 592 473 82 179 26 629 574 991 148 267 656 243 180 715 572 519 954 193 578 215 56 387 892 447 296 51 30 621...

output:

124859
993
992
991
990
989
988
987
986
985
984
983
982
981
980
979
978
977
976
975
974
973
972
971
970
969
968
967
966
965
964
963
962
959
958
957
956
955
954
953
952
951
950
949
948
947
946
945
944
943
942
941
940
939
938
937
936
935
934
933
932
930
929
928
927
926
925
924
923
922
921
920
919
918
9...

result:

ok Perfect :) Use 124859 operations

Test #276:

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

input:

15 1000 5
79 918 337 906 823 762 397 436 243 434 569 546 297 794 301 440 679 892 359 932 71 886 721 216 825 458 205 652 425 16 877 234 69 200 731 926 505 596 551 406 585 236 351 900 739 640 715 600 139 262 655 122 831 536 787 876 757 286 811 32 25 112 819 890 11 134 635 70 631 994 387 30 885 812 533...

output:

64520
529
533
537
541
545
549
553
557
561
565
569
573
577
581
585
589
593
597
601
605
609
613
617
621
625
629
633
637
641
645
649
653
657
661
665
669
673
677
681
685
689
693
697
701
705
709
713
717
721
725
729
733
737
741
745
749
753
757
761
765
769
773
777
781
785
789
793
797
801
805
809
813
817
82...

result:

ok Perfect :) Use 64520 operations

Test #277:

score: 15
Accepted
time: 3ms
memory: 3704kb

input:

15 1000 5
283 152 755 598 437 80 255 936 93 272 889 150 451 894 175 918 99 92 719 824 3 1000 491 78 65 282 841 356 699 816 265 166 293 406 269 914 547 926 373 218 621 828 585 760 995 364 417 512 375 928 535 546 703 286 51 572 345 540 977 196 871 100 101 608 763 138 503 858 263 6 343 430 735 122 573 ...

output:

-1

result:

ok No solutions

Test #278:

score: 15
Accepted
time: 5ms
memory: 3704kb

input:

15 1000 7
453 146 677 538 23 588 221 302 401 564 277 498 269 232 229 18 155 888 747 360 903 768 761 40 641 134 21 772 93 616 185 750 965 792 151 226 655 4 613 56 3 354 125 754 589 294 745 170 535 492 941 872 851 746 649 238 775 324 105 910 475 964 469 22 795 904 693 566 349 630 923 382 457 268 635 7...

output:

42877
775
781
787
793
799
805
811
817
823
829
835
841
847
853
859
865
871
877
883
889
895
901
907
913
919
925
931
937
943
949
955
961
967
973
979
985
991
992
993
776
782
788
794
800
806
812
818
824
830
836
842
848
854
860
866
872
878
884
890
896
902
908
914
920
926
932
938
944
950
956
962
968
974
98...

result:

ok Perfect :) Use 42877 operations

Test #279:

score: 15
Accepted
time: 4ms
memory: 3600kb

input:

15 1000 9
879 862 851 936 377 980 861 160 181 168 919 866 595 728 257 708 449 896 139 298 645 290 141 490 779 616 409 206 615 826 491 390 997 838 119 334 341 622 809 108 827 400 77 710 21 236 849 144 43 480 539 510 677 670 389 720 531 586 699 754 309 436 303 498 855 256 261 166 433 886 783 360 917 6...

output:

32522
771
779
787
795
803
811
819
827
835
843
851
859
867
875
883
891
899
907
915
923
931
939
947
955
963
971
979
987
989
991
96
104
112
120
128
136
144
152
160
168
176
184
192
200
208
216
224
232
240
248
256
264
272
280
288
296
304
312
320
328
336
344
352
360
368
376
384
392
400
408
416
424
432
440...

result:

ok Perfect :) Use 32522 operations

Test #280:

score: 15
Accepted
time: 2ms
memory: 3776kb

input:

15 1000 9
421 10 975 818 495 518 963 404 625 322 695 176 785 508 769 110 63 884 573 496 539 568 823 646 459 890 483 754 391 196 153 968 613 490 59 796 225 578 407 842 711 454 19 172 697 84 115 700 95 930 971 732 601 502 491 472 881 726 849 798 565 220 147 168 121 750 983 398 49 690 609 312 743 692 6...

output:

-1

result:

ok No solutions

Subtask #16:

score: 5
Accepted

Test #281:

score: 5
Accepted
time: 2ms
memory: 3528kb

input:

16 1000 1000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...

output:

0

result:

ok Perfect :) Use 0 operations

Test #282:

score: 5
Accepted
time: 2ms
memory: 3456kb

input:

16 1000 1000
913 227 730 357 862 645 631 393 32 331 181 324 798 469 402 999 936 158 385 956 419 430 46 592 550 655 841 221 541 664 109 334 440 270 502 740 888 177 501 537 72 311 243 382 284 836 488 498 113 995 81 770 720 345 949 37 709 49 235 274 659 84 695 948 234 471 288 604 877 554 678 468 517 54...

output:

-1

result:

ok No solutions

Test #283:

score: 5
Accepted
time: 2ms
memory: 3500kb

input:

16 1000 1000
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165...

output:

-1

result:

ok No solutions

Test #284:

score: 5
Accepted
time: 1ms
memory: 3396kb

input:

16 999 998
874 873 872 871 870 869 868 867 866 865 864 863 862 861 860 859 858 857 856 855 854 853 852 851 850 849 848 847 846 845 844 843 842 841 840 839 838 837 836 835 834 833 832 831 830 829 828 827 826 825 824 823 822 821 820 819 818 817 816 815 814 813 812 811 810 809 808 807 806 805 804 803 8...

output:

125
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0

result:

ok Perfect :) Use 125 operations

Test #285:

score: 5
Accepted
time: 2ms
memory: 3636kb

input:

16 999 998
461 792 701 275 902 634 949 637 39 689 476 260 276 875 438 698 311 496 410 682 432 173 818 399 943 160 364 961 560 150 929 891 301 958 271 129 995 318 359 354 148 539 17 705 741 986 337 839 926 174 908 11 238 938 373 869 817 652 225 255 816 683 376 973 942 380 773 602 437 145 716 205 166 ...

output:

-1

result:

ok No solutions

Test #286:

score: 5
Accepted
time: 152ms
memory: 8684kb

input:

16 1000 998
521 479 831 13 657 827 236 789 544 458 169 130 548 160 549 88 156 865 626 440 678 312 722 138 116 283 513 897 473 676 615 19 991 745 898 313 54 737 431 137 580 887 997 171 294 983 528 778 339 396 864 319 393 495 131 23 465 602 717 32 640 181 679 646 65 173 427 163 956 814 982 762 43 613 ...

output:

999563
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1...

result:

ok Perfect :) Use 999563 operations

Test #287:

score: 5
Accepted
time: 146ms
memory: 7884kb

input:

16 1000 998
611 895 676 381 211 229 415 807 720 36 529 306 580 337 526 751 506 677 545 725 203 61 623 869 516 147 472 726 727 881 228 615 600 987 263 349 794 924 989 179 594 669 680 990 929 100 275 484 515 91 944 146 174 108 960 701 556 834 745 48 379 480 931 649 94 894 912 766 265 489 115 494 758 8...

output:

997811
0
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1...

result:

ok Perfect :) Use 997811 operations

Test #288:

score: 5
Accepted
time: 140ms
memory: 7528kb

input:

16 1000 998
808 728 952 710 104 813 671 545 727 16 712 380 295 378 47 930 258 713 253 386 101 648 319 678 206 516 167 479 213 907 823 485 973 514 659 197 320 425 308 399 844 588 137 171 472 257 299 347 506 575 766 139 406 57 623 151 549 694 984 517 329 259 816 584 554 915 441 568 636 237 337 852 13 ...

output:

997370
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2...

result:

ok Perfect :) Use 997370 operations

Test #289:

score: 5
Accepted
time: 155ms
memory: 7604kb

input:

16 1000 998
693 614 871 604 276 365 433 46 367 968 978 870 161 187 147 561 277 815 28 829 300 40 952 861 611 1000 149 776 511 986 255 547 707 930 228 589 732 934 326 771 747 809 168 937 989 767 217 448 154 184 851 443 48 770 346 331 461 344 44 210 360 791 546 36 59 417 164 458 672 55 124 24 353 633 ...

output:

997475
0
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2...

result:

ok Perfect :) Use 997475 operations

Test #290:

score: 5
Accepted
time: 114ms
memory: 9164kb

input:

16 1000 900
874 954 794 58 543 682 81 186 460 454 334 193 249 675 332 495 147 307 493 63 208 593 52 350 398 482 217 863 204 203 69 378 24 877 565 253 40 78 261 897 397 14 362 999 529 514 842 599 578 435 969 513 451 952 142 343 880 815 597 228 674 136 200 480 161 866 463 57 388 739 765 937 635 45 622...

output:

852314
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99
100
99...

result:

ok Perfect :) Use 852314 operations

Test #291:

score: 5
Accepted
time: 136ms
memory: 7520kb

input:

16 1000 996
878 559 590 170 422 19 866 166 504 570 799 572 961 264 809 879 962 541 91 142 568 926 737 550 996 591 929 750 731 801 633 902 175 685 682 478 490 246 479 620 747 98 473 862 518 207 881 617 171 21 637 887 45 630 953 689 48 310 810 364 838 495 913 262 738 715 999 240 552 554 230 210 234 68...

output:

994401
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4...

result:

ok Perfect :) Use 994401 operations

Test #292:

score: 5
Accepted
time: 149ms
memory: 9020kb

input:

16 1000 996
655 189 271 905 416 342 908 831 226 520 948 946 824 529 383 760 321 662 996 2 532 646 4 913 475 706 718 489 514 587 497 945 82 974 780 397 177 373 973 958 643 154 328 876 915 747 764 203 492 39 85 83 326 851 409 707 155 677 318 671 330 766 527 288 939 531 205 63 984 726 861 689 993 368 7...

output:

994342
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3...

result:

ok Perfect :) Use 994342 operations

Test #293:

score: 5
Accepted
time: 139ms
memory: 9476kb

input:

16 1000 996
287 261 238 513 726 296 825 466 176 378 131 43 20 85 618 587 521 104 363 58 402 109 811 384 136 57 46 607 421 65 628 309 295 310 282 387 952 832 659 263 575 919 33 340 389 27 501 789 527 90 339 364 366 799 494 344 412 924 264 580 805 641 474 781 152 383 657 465 237 281 937 468 407 583 96...

output:

995825
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4...

result:

ok Perfect :) Use 995825 operations

Test #294:

score: 5
Accepted
time: 97ms
memory: 8880kb

input:

16 1000 996
931 749 36 152 333 315 52 504 330 372 106 486 650 31 364 604 860 44 436 949 469 176 865 775 308 343 591 294 988 142 715 303 347 451 528 690 574 867 187 773 379 941 110 179 783 778 525 496 863 450 876 900 897 856 492 599 233 423 520 72 230 846 311 60 950 177 125 683 910 614 136 305 357 76...

output:

-1

result:

ok No solutions

Test #295:

score: 5
Accepted
time: 9ms
memory: 4204kb

input:

16 1000 2
33 217 532 454 152 514 858 977 352 203 873 433 167 614 300 475 90 492 244 666 482 746 882 260 243 631 579 825 349 206 213 305 350 366 125 795 247 570 774 799 375 711 500 74 915 362 466 469 960 10 358 32 8 506 473 385 351 762 984 53 493 40 755 162 293 737 490 483 968 749 808 405 525 147 63 ...

output:

239363
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
8...

result:

ok Perfect :) Use 239363 operations

Test #296:

score: 5
Accepted
time: 2ms
memory: 3812kb

input:

16 1000 4
596 636 414 372 416 539 426 934 109 313 598 567 755 533 199 117 465 559 486 593 622 179 766 237 180 642 353 141 122 782 27 834 51 48 349 792 39 290 67 731 963 843 606 261 56 804 190 394 43 956 64 386 73 802 626 625 894 831 658 368 35 709 354 304 512 267 167 680 436 988 656 336 788 90 616 2...

output:

-1

result:

ok No solutions

Test #297:

score: 5
Accepted
time: 4ms
memory: 3832kb

input:

16 1000 4
607 892 180 508 412 184 482 262 590 220 340 1 487 715 571 774 479 254 289 949 987 405 639 99 319 790 858 336 855 518 369 129 253 169 998 787 33 438 66 29 541 435 896 490 46 304 829 591 43 62 442 178 381 653 15 728 86 830 972 242 68 195 79 995 283 781 352 243 547 136 613 724 45 707 898 266 ...

output:

82618
198
201
204
207
210
213
216
219
222
225
228
231
234
237
240
243
246
249
252
255
258
261
264
267
270
273
276
279
282
285
288
291
294
297
300
303
306
309
312
315
318
321
324
327
330
333
336
339
342
345
348
351
354
357
360
363
366
369
372
375
378
381
384
387
390
393
396
399
402
405
408
411
414
41...

result:

ok Perfect :) Use 82618 operations

Test #298:

score: 5
Accepted
time: 6ms
memory: 3676kb

input:

16 1000 6
129 602 751 243 739 15 825 63 293 569 407 34 647 968 442 11 408 632 590 789 838 574 483 889 84 835 874 923 3 811 559 208 716 840 401 248 703 828 955 125 324 675 335 224 971 543 486 480 479 757 657 611 916 954 441 176 685 386 983 60 274 509 50 80 736 581 223 566 601 681 709 783 78 778 864 9...

output:

53356
131
136
141
146
151
156
161
166
171
176
181
186
191
196
201
206
211
216
221
226
231
236
241
246
251
256
261
266
271
276
281
286
291
296
301
306
311
316
321
326
331
336
341
346
351
356
361
366
371
376
381
386
391
396
401
406
411
416
421
426
431
436
441
446
451
456
461
466
471
476
481
486
491
49...

result:

ok Perfect :) Use 53356 operations

Test #299:

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

input:

16 1000 52
517 935 588 746 288 161 579 233 829 909 677 239 278 665 682 822 49 441 630 84 738 581 164 430 729 861 828 875 445 112 326 949 761 603 255 736 369 852 539 888 808 622 885 258 269 721 702 597 421 86 718 526 607 955 149 833 313 767 864 475 74 766 929 608 582 479 250 956 771 280 465 813 446 2...

output:

-1

result:

ok No solutions

Test #300:

score: 5
Accepted
time: 3ms
memory: 3564kb

input:

16 1000 52
791 927 451 670 756 465 741 855 648 431 524 434 290 186 72 268 778 174 926 124 322 155 181 298 145 525 588 835 216 760 620 2 671 873 965 753 660 610 127 762 133 657 861 914 188 872 827 394 444 638 572 482 938 830 573 158 795 765 198 976 739 838 439 378 539 160 999 325 376 570 899 380 445 ...

output:

10131
195
246
297
348
399
450
501
552
603
654
705
756
807
858
909
948
942
948
66
117
168
219
270
321
372
423
474
525
576
627
678
729
780
831
882
933
940
947
687
738
789
840
891
942
944
946
774
825
876
927
936
945
271
322
373
424
475
526
577
628
679
730
781
832
883
934
939
944
438
489
540
591
642
693...

result:

ok Perfect :) Use 10131 operations