QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#79827#5525. Increasing Gridyuto1115AC ✓23ms6176kbC++1711.8kb2023-02-20 23:36:432023-02-20 23:36:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-20 23:36:45]
  • 评测
  • 测评结果:AC
  • 用时:23ms
  • 内存:6176kb
  • [2023-02-20 23:36:43]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(i, n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i, s, n) for (ll i = ll(s); i < ll(n); ++i)
#define rep3(i, s, n, d) for(ll i = ll(s); i < ll(n); i+=d)
#define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(i, n) for (ll i = ll(n)-1; i >= 0; i--)
#define rrep2(i, n, t) for (ll i = ll(n)-1; i >= (ll)t; i--)
#define rrep3(i, n, t, d) for (ll i = ll(n)-1; i >= (ll)t; i-=d)
#define rrep(...) overload4(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SUM(a) accumulate(all(a),0LL)
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SORT(a) sort(all(a));
#define REV(a) reverse(all(a));
#define SZ(a) int(a.size())
#define popcount(x) __builtin_popcountll(x)
#define pf push_front
#define pb push_back
#define ef emplace_front
#define eb emplace_back
#define ppf pop_front
#define ppb pop_back
#ifdef __LOCAL
#define debug(...) { cout << #__VA_ARGS__; cout << ": "; print(__VA_ARGS__); cout << flush; }
#else
#define debug(...) void(0);
#endif
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vp = vector<P>;
using vvp = vector<vp>;
using vlp = vector<LP>;
using vvlp = vector<vlp>;
template<class T>
using PQ = priority_queue<T>;
template<class T>
using PQrev = priority_queue<T, vector<T>, greater<T>>;

template<class S, class T>
istream &operator>>(istream &is, pair<S, T> &p) { return is >> p.first >> p.second; }

template<class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &p) { return os << '{' << p.first << ", " << p.second << '}'; }

template<class S, class T, class U>
istream &operator>>(istream &is, tuple<S, T, U> &t) { return is >> get<0>(t) >> get<1>(t) >> get<2>(t); }

template<class S, class T, class U>
ostream &operator<<(ostream &os, const tuple<S, T, U> &t) {
    return os << '{' << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << '}';
}

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t: v) { is >> t; }
    return is;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '[';
    rep(i, v.size()) os << v[i] << (i == int(v.size() - 1) ? "" : ", ");
    return os << ']';
}

template<class T>
ostream &operator<<(ostream &os, const deque<T> &v) {
    os << '[';
    rep(i, v.size()) os << v[i] << (i == int(v.size() - 1) ? "" : ", ");
    return os << ']';
}

template<class T>
ostream &operator<<(ostream &os, const set<T> &st) {
    os << '{';
    auto it = st.begin();
    while (it != st.end()) {
        os << (it == st.begin() ? "" : ", ") << *it;
        it++;
    }
    return os << '}';
}

template<class T>
ostream &operator<<(ostream &os, const multiset<T> &st) {
    os << '{';
    auto it = st.begin();
    while (it != st.end()) {
        os << (it == st.begin() ? "" : ", ") << *it;
        it++;
    }
    return os << '}';
}

template<class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &mp) {
    os << '{';
    auto it = mp.begin();
    while (it != mp.end()) {
        os << (it == mp.begin() ? "" : ", ") << *it;
        it++;
    }
    return os << '}';
}

template<class T>
void vecout(const vector<T> &v, char div = '\n') {
    rep(i, v.size()) cout << v[i] << (i == int(v.size() - 1) ? '\n' : div);
}

template<class T>
bool constexpr chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool constexpr chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void scan() {}

template<class Head, class... Tail>
void scan(Head &head, Tail &... tail) {
    cin >> head;
    scan(tail...);
}

template<class T>
void print(const T &t) { cout << t << '\n'; }

template<class Head, class... Tail>
void print(const Head &head, const Tail &... tail) {
    cout << head << ' ';
    print(tail...);
}

template<class T>
vector<T> &operator+=(vector<T> &v, T x) {
    for (T &t: v) t += x;
    return v;
}

template<class T>
vector<T> &operator-=(vector<T> &v, T x) {
    for (T &t: v) t -= x;
    return v;
}

template<class T>
vector<T> &operator*=(vector<T> &v, T x) {
    for (T &t: v) t *= x;
    return v;
}

template<class T>
vector<T> &operator/=(vector<T> &v, T x) {
    for (T &t: v) t /= x;
    return v;
}

struct Init_io {
    Init_io() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout << boolalpha << fixed << setprecision(15);
        cerr << boolalpha << fixed << setprecision(15);
    }
} init_io;

const string yes[] = {"no", "yes"};
const string Yes[] = {"No", "Yes"};
const string YES[] = {"NO", "YES"};
const int inf = 1001001001;
const ll linf = 1001001001001001001;

void rearrange(const vi &) {}

template<class T, class... Tail>
void rearrange(const vi &ord, vector<T> &head, Tail &...tail) {
    assert(ord.size() == head.size());
    vector<T> ori = head;
    rep(i, ord.size()) head[i] = ori[ord[i]];
    rearrange(ord, tail...);
}

template<class T, class... Tail>
void sort_by(vector<T> &head, Tail &... tail) {
    vi ord(head.size());
    iota(all(ord), 0);
    sort(all(ord), [&](int i, int j) { return head[i] < head[j]; });
    rearrange(ord, head, tail...);
}

bool in_rect(int i, int j, int h, int w) {
    return 0 <= i and i < h and 0 <= j and j < w;
}

template<class T>
constexpr vector<T> pow_table(int n, T base) {
    vector<T> res(n, 1);
    rep(i, n - 1) res[i + 1] = res[i] * base;
    return res;
}

template<class T, class S>
vector<T> cumsum(const vector<S> &v, bool shift_one = true) {
    int n = v.size();
    vector<T> res;
    if (shift_one) {
        res.resize(n + 1);
        rep(i, n) res[i + 1] = res[i] + v[i];
    } else {
        res.resize(n);
        if (n) {
            res[0] = v[0];
            rep(i, 1, n) res[i] = res[i - 1] + v[i];
        }
    }
    return res;
}

vvi graph(int n, int m, bool directed = false, int origin = 1) {
    vvi G(n);
    rep(_, m) {
        INT(u, v);
        u -= origin, v -= origin;
        G[u].pb(v);
        if (!directed) G[v].pb(u);
    }
    return G;
}

template<class T>
vector<vector<pair<int, T>>> weighted_graph(int n, int m, bool directed = false, int origin = 1) {
    vector<vector<pair<int, T>>> G(n);
    rep(_, m) {
        int u, v;
        T w;
        scan(u, v, w);
        u -= origin, v -= origin;
        G[u].eb(v, w);
        if (!directed) G[v].eb(u, w);
    }
    return G;
}

template<int mod>
class modint {
    ll x;
public:
    constexpr modint(ll x = 0) : x((x % mod + mod) % mod) {}
    
    static constexpr int get_mod() { return mod; }
    
    constexpr int val() const { return x; }
    
    constexpr modint operator-() const { return modint(-x); }
    
    constexpr modint &operator+=(const modint &a) {
        if ((x += a.val()) >= mod) x -= mod;
        return *this;
    }
    
    constexpr modint &operator++() { return *this += 1; }
    
    constexpr modint &operator-=(const modint &a) {
        if ((x += mod - a.val()) >= mod) x -= mod;
        return *this;
    }
    
    constexpr modint &operator--() { return *this -= 1; }
    
    constexpr modint &operator*=(const modint &a) {
        (x *= a.val()) %= mod;
        return *this;
    }
    
    constexpr modint operator+(const modint &a) const {
        modint res(*this);
        return res += a;
    }
    
    constexpr modint operator-(const modint &a) const {
        modint res(*this);
        return res -= a;
    }
    
    constexpr modint operator*(const modint &a) const {
        modint res(*this);
        return res *= a;
    }
    
    constexpr modint pow(ll t) const {
        modint res = 1, a(*this);
        while (t > 0) {
            if (t & 1) res *= a;
            t >>= 1;
            a *= a;
        }
        return res;
    }
    
    template<int m>
    friend istream &operator>>(istream &, modint<m> &);
    
    // for prime mod
    constexpr modint inv() const { return pow(mod - 2); }
    
    constexpr modint &operator/=(const modint &a) { return *this *= a.inv(); }
    
    constexpr modint operator/(const modint &a) const {
        modint res(*this);
        return res /= a;
    }
    
    // constraints : mod = 2 or val = 0 or val^((mod-1)/2) ≡ 1
    //               mod is prime
    // time complexity : O(log^2 p)
    // reference : https://nyaannyaan.github.io/library/modulo/mod-sqrt.hpp
    modint sqrt() const {
        if (x < 2) return x;
        assert(this->pow((mod - 1) >> 1).val() == 1);
        modint b = 1;
        while (b.pow((mod - 1) >> 1).val() == 1) b += 1;
        ll m = mod - 1, e = 0;
        while (~m & 1) m >>= 1, e += 1;
        modint X = this->pow((m - 1) >> 1);
        modint Y = (*this) * X * X;
        X *= *this;
        modint Z = b.pow(m);
        while (Y.val() != 1) {
            ll j = 0;
            modint t = Y;
            while (t.val() != 1) {
                j += 1;
                t *= t;
            }
            Z = Z.pow(1LL << (e - j - 1));
            X *= Z;
            Z *= Z;
            Y *= Z;
            e = j;
        }
        return X;
    }
};

using modint998244353 = modint<998244353>;
using modint1000000007 = modint<1000000007>;

template<int mod>
istream &operator>>(istream &is, modint<mod> &a) {
    ll x;
    is >> x;
    a = modint<mod>(x);
    return is;
}

template<int mod>
constexpr ostream &operator<<(ostream &os, const modint<mod> &a) { return os << a.val(); }

template<int mod>
constexpr bool operator==(const modint<mod> &a, const modint<mod> &b) { return a.val() == b.val(); }

template<int mod>
constexpr bool operator!=(const modint<mod> &a, const modint<mod> &b) { return a.val() != b.val(); }

template<int mod>
constexpr modint<mod> &operator++(modint<mod> &a) { return a += 1; }

template<int mod>
constexpr modint<mod> &operator--(modint<mod> &a) { return a -= 1; }

using mint = modint998244353;

using vm = vector<mint>;
using vvm = vector<vm>;

void solve() {
    INT(n, m);
    vvi a(n, vi(m));
    scan(a);
    vi l(n), r(n, m);
    rep(i, n) rep(j, m) {
            if (a[i][j] == -1) continue;
            int now = a[i][j] - (i + j + 1);
            if (now < 0 or now > 1) {
                print(0);
                return;
            }
            if (!now) chmax<int>(l[i], j + 1);
            else chmin<int>(r[i], j);
        }
    vvm dp(n + 1, vm(m + 1));
    dp[0][m] = 1;
    rep(i, n) {
        dp[i + 1] = dp[i];
        rrep(j, m) dp[i + 1][j] += dp[i + 1][j + 1];
        rep(j, m + 1) if (j < l[i] or j > r[i]) dp[i + 1][j] = 0;
    }
    print(accumulate(all(dp[n]), mint(0)));
}

int main() {
    int t;
    cin >> t;
    rep(i, t) solve();
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3408kb

input:

4
2 3
1 2 -1
-1 4 5
4 4
-1 -1 -1 -1
-1 -1 -1 -1
-1 4 4 -1
-1 -1 -1 -1
4 4
-1 -1 -1 -1
-1 -1 -1 -1
-1 4 5 -1
-1 -1 -1 -1
3 5
1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1

output:

4
0
17
55

result:

ok 4 number(s): "4 0 17 55"

Test #2:

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

input:

1
2857 70
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

266977954

result:

ok 1 number(s): "266977954"

Test #3:

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

input:

1
3225 62
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

43003510

result:

ok 1 number(s): "43003510"

Test #4:

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

input:

1
34 5882
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

181277996

result:

ok 1 number(s): "181277996"

Test #5:

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

input:

1
6 33333
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

942557054

result:

ok 1 number(s): "942557054"

Test #6:

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

input:

1
470 425
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

321320838

result:

ok 1 number(s): "321320838"

Test #7:

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

input:

3
406 164
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

100583745
965682993
506401552

result:

ok 3 number(s): "100583745 965682993 506401552"

Test #8:

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

input:

3
617 108
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

155894158
696179809
26941117

result:

ok 3 number(s): "155894158 696179809 26941117"

Test #9:

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

input:

3
784 85
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

737523059
603224993
597349569

result:

ok 3 number(s): "737523059 603224993 597349569"

Test #10:

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

input:

3
29 2298
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

396891105
947304368
510868160

result:

ok 3 number(s): "396891105 947304368 510868160"

Test #11:

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

input:

3
247 269
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

379112706
335134214
355847359

result:

ok 3 number(s): "379112706 335134214 355847359"

Test #12:

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

input:

10
204 98
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

61226798
40628357
439703518
849778142
656626189
169864409
849924485
969955039
428968320
858402932

result:

ok 10 numbers

Test #13:

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

input:

100
74 27
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

626032214
502739587
940612786
578571800
88511598
317568922
846512485
662780782
971010183
361731076
838456187
444876395
546444396
361731076
49679494
756067232
127657859
626032214
345074838
501501
612101462
304454789
317568922
304454789
546444396
683337149
679990133
794529481
2001
846512485
124419476
...

result:

ok 100 numbers

Test #14:

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

input:

1000
14 14
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

40116600
1221759
5151
1221759
20160075
40116600
30045015
40116600
13884156
6724520
40116600
37442160
34597290
37442160
6724520
316251
3262623
316251
40116600
30045015
201
30421755
30045015
30045015
316251
52394
37442160
1221759
34597290
52394
3262623
316251
201
6724520
40116600
1221759
13884156
4011...

result:

ok 1000 numbers

Test #15:

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

input:

10000
20 1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3 6
-1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1
4 5
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
4 5
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
-1 -1 -1 -1 -1
10 2
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1...

output:

21
84
126
126
66
84
21
21
84
126
21
66
21
21
21
21
66
21
84
66
84
66
66
66
126
21
126
84
84
84
84
21
126
126
66
21
21
84
126
21
84
84
21
21
66
66
21
66
84
21
84
66
21
126
84
21
84
66
66
126
66
66
21
21
126
66
66
126
66
84
126
66
126
66
21
21
84
126
66
21
66
21
21
84
126
126
66
21
66
126
21
84
66
84
...

result:

ok 10000 numbers

Test #16:

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

input:

1
2857 70
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

226015187

result:

ok 1 number(s): "226015187"

Test #17:

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

input:

1
3225 62
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

927015823

result:

ok 1 number(s): "927015823"

Test #18:

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

input:

1
34 5882
1 -1 3 -1 -1 6 7 8 9 -1 11 12 -1 14 15 -1 -1 18 -1 20 21 22 -1 -1 25 26 27 28 29 30 31 -1 -1 -1 -1 36 -1 38 -1 -1 -1 -1 43 44 -1 -1 -1 48 -1 50 51 -1 -1 54 -1 56 -1 -1 59 60 -1 62 63 64 65 -1 67 -1 -1 -1 -1 -1 73 74 75 -1 77 -1 79 80 81 -1 83 -1 85 86 87 88 89 -1 91 92 93 94 95 96 97 98 -1...

output:

990886230

result:

ok 1 number(s): "990886230"

Test #19:

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

input:

1
6 33333
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

422786771

result:

ok 1 number(s): "422786771"

Test #20:

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

input:

1
470 425
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

877984607

result:

ok 1 number(s): "877984607"

Test #21:

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

input:

3
406 164
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

326935456
584792895
464096788

result:

ok 3 number(s): "326935456 584792895 464096788"

Test #22:

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

input:

3
617 108
-1 -1 -1 4 -1 -1 7 -1 9 10 -1 12 13 14 15 -1 17 -1 19 -1 -1 -1 -1 24 25 -1 -1 -1 29 -1 31 32 -1 -1 35 -1 -1 -1 39 -1 -1 42 43 -1 -1 -1 47 48 49 -1 -1 52 -1 54 55 56 57 58 59 -1 61 62 -1 64 65 66 -1 -1 -1 70 71 -1 -1 74 -1 -1 -1 78 -1 -1 -1 -1 83 84 -1 86 -1 -1 -1 90 91 92 -1 94 95 -1 97 -1...

output:

364084446
692976084
535691147

result:

ok 3 number(s): "364084446 692976084 535691147"

Test #23:

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

input:

3
784 85
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

408436895
106596377
329390492

result:

ok 3 number(s): "408436895 106596377 329390492"

Test #24:

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

input:

3
29 2298
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

488213402
857645806
987649594

result:

ok 3 number(s): "488213402 857645806 987649594"

Test #25:

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

input:

3
247 269
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

901504397
956940083
609589347

result:

ok 3 number(s): "901504397 956940083 609589347"

Test #26:

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

input:

10
204 98
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

423835890
772235276
655736616
170741944
25381097
793735997
16194064
4
192
522241336

result:

ok 10 numbers

Test #27:

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

input:

100
74 27
-1 -1 3 4 5 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 19 20 21 22 -1 -1 25 -1 27
-1 -1 -1 -1 -1 -1 -1 -1 10 -1 12 13 -1 -1 -1 17 18 19 -1 -1 22 -1 24 25 26 -1 -1
3 -1 5 -1 -1 8 -1 -1 -1 12 13 -1 -1 -1 -1 18 19 20 -1 22 -1 -1 -1 -1 27 -1 -1
-1 -1 -1 -1 -1 9 -1 11 12 13 14 15 -1 -1 18 -1 -1 21 -...

output:

694977529
296372109
961307647
302497360
294566522
410164164
135
868063660
752605382
664715962
117696471
221184
96768
76608
944234136
225917224
209375095
38367
108
158735542
552772149
308270859
623714867
276214491
630502747
509548188
778934141
265571436
343358036
830148880
47520
4992
23077887
8555835...

result:

ok 100 numbers

Test #28:

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

input:

1000
14 14
-1 -1 -1 4 -1 -1 -1 8 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 16 -1
-1 -1 -1 -1 -1 -1 -1 -1 13 -1 -1 -1 -1 -1
-1 7 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

4116125
64
2281400
27720
17133020
60
8
36
977980
238560
39694
6
1430
16
440
816
4504
1540962
25637976
451
11623030
1088
12
1714669
19955909
849387
24
12288
128
9381848
2857855
247800
120
66582
6054087
1082706
16
343710
54
24866478
49469
8
612
320
7368240
651287
24
640
240
24677926
1440
24506482
8073...

result:

ok 1000 numbers

Test #29:

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

input:

10000
20 1
-1
-1
-1
-1
6
7
-1
9
10
-1
-1
-1
-1
-1
-1
-1
-1
-1
20
-1
20 1
-1
-1
4
-1
-1
7
-1
9
10
-1
-1
-1
-1
15
16
17
18
-1
20
21
10 2
1 -1
2 -1
-1 -1
-1 6
-1 -1
6 8
7 9
8 -1
9 -1
-1 -1
1 20
1 2 -1 -1 5 6 -1 -1 9 -1 -1 -1 -1 -1 -1 17 -1 -1 -1 -1
2 10
1 -1 -1 4 5 -1 -1 9 -1 -1
-1 -1 4 5 -1 8 9 -1 11 ...

output:

5
3
8
7
6
1
14
2
56
60
21
4
1
9
5
7
12
3
1
3
24
6
5
3
5
76
17
19
15
11
12
17
14
12
1
70
2
7
6
5
8
7
25
4
3
7
8
17
24
5
45
20
20
6
9
11
13
3
9
6
6
1
5
63
48
15
7
16
7
10
5
12
8
12
3
2
24
1
28
9
75
4
1
4
60
71
1
2
7
4
15
9
7
12
9
2
72
4
11
4
8
3
9
20
2
4
10
60
12
51
81
3
9
36
2
1
18
24
7
3
2
20
2
1
8
...

result:

ok 10000 numbers

Test #30:

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

input:

1
2857 70
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0

result:

ok 1 number(s): "0"

Test #31:

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

input:

1
3225 62
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0

result:

ok 1 number(s): "0"

Test #32:

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

input:

1
34 5882
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0

result:

ok 1 number(s): "0"

Test #33:

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

input:

1
6 33333
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0

result:

ok 1 number(s): "0"

Test #34:

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

input:

1
470 425
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

890874805

result:

ok 1 number(s): "890874805"

Test #35:

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

input:

3
406 164
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0
0
692246464

result:

ok 3 number(s): "0 0 692246464"

Test #36:

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

input:

3
617 108
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

379270627
830168837
0

result:

ok 3 number(s): "379270627 830168837 0"

Test #37:

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

input:

3
784 85
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

683914361
0
0

result:

ok 3 number(s): "683914361 0 0"

Test #38:

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

input:

3
29 2298
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0
0
0

result:

ok 3 number(s): "0 0 0"

Test #39:

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

input:

3
247 269
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0
163867028
314228181

result:

ok 3 number(s): "0 163867028 314228181"

Test #40:

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

input:

10
204 98
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

977871808
0
452851657
0
956810861
165517803
0
60504822
632702764
0

result:

ok 10 numbers

Test #41:

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

input:

100
74 27
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0
0
284542063
0
996507058
643504531
0
172034941
0
0
865745389
513166363
376276690
0
876231714
0
0
0
0
0
935471683
0
937930370
164057082
0
0
0
0
158671184
0
0
590035196
0
797759166
0
0
0
0
99743472
0
0
0
0
0
34944594
0
279799476
0
0
0
0
0
430525026
377470096
28587772
0
0
741007574
0
0
0
577605907
977...

result:

ok 100 numbers

Test #42:

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

input:

1000
14 14
-1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 15 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 17 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0
0
0
0
0
0
0
0
0
0
0
10530
184870
22386
0
0
350
6720143
9327696
0
0
0
0
0
5328687
0
0
0
0
0
12397
0
0
15301
0
0
0
0
0
0
0
857208
0
0
18575
0
0
7220
99968
94240
5040
0
0
0
0
1000792
0
875150
0
10846143
0
2244
0
0
334125
0
0
22638
0
0
0
37542195
0
0
0
0
0
0
0
0
7102753
0
33649
0
30032464
0
5910900
0
...

result:

ok 1000 numbers

Test #43:

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

input:

10000
20 1
-1
3
-1
-1
-1
6
8
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
20
-1
20 1
-1
2
-1
-1
-1
7
-1
-1
-1
-1
-1
-1
13
-1
-1
-1
18
-1
19
20
20 1
-1
-1
-1
-1
5
-1
-1
-1
-1
-1
-1
-1
13
-1
-1
-1
-1
18
-1
-1
2 10
-1 -1 -1 -1 -1 6 -1 -1 -1 11
-1 -1 -1 -1 -1 -1 8 -1 10 -1
20 1
1
-1
-1
-1
-1
-1
8
9
-1
-1
-1
-1
13
-...

output:

0
0
3
1
0
21
0
0
2
5
1
0
1
0
0
0
75
2
21
12
0
80
0
35
0
21
0
0
64
4
15
29
0
3
56
0
0
0
0
4
2
6
3
0
0
0
10
0
1
0
5
0
18
0
0
0
2
106
0
0
0
0
0
0
4
0
1
10
0
0
15
25
21
35
15
3
0
51
0
64
0
0
3
0
19
0
0
0
0
0
9
0
0
0
0
0
3
0
0
0
16
1
20
0
0
17
4
55
0
45
1
0
0
0
51
0
29
0
8
13
0
0
111
8
0
0
0
0
0
10
6
3
0...

result:

ok 10000 numbers