QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105931#5743. Palindromic PolynomialmaspyAC ✓145ms4160kbC++2340.9kb2023-05-16 01:02:152023-05-16 01:02:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-16 01:02:18]
  • 评测
  • 测评结果:AC
  • 用时:145ms
  • 内存:4160kb
  • [2023-05-16 01:02:15]
  • 提交

answer

#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) \
  for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T, typename U>
T ceil(T x, U y) {
  return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U>
T floor(T x, U y) {
  return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T, typename U>
pair<T, T> divmod(T x, U y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sum = 0;
  for (auto &&a: A) sum += a;
  return sum;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  assert(!que.empty());
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  assert(!que.empty());
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng) {
  assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids),
       [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}
#endif
#line 1 "library/other/io.hpp"
// based on yosupo's fastio
#include <unistd.h>

namespace fastio {
#define FASTIO
// クラスが read(), print() を持っているかを判定するメタ関数
struct has_write_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.write(), std::true_type{});

  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_write : public decltype(has_write_impl::check<T>(std::declval<T>())) {
};

struct has_read_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.read(), std::true_type{});

  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_read : public decltype(has_read_impl::check<T>(std::declval<T>())) {};

struct Scanner {
  FILE *fp;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += fread(line + ed, 1, (1 << 15) - ed, fp);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) { ref = 10 * ref + (line[st++] & 0xf); }
    if (neg) ref = -ref;
    return true;
  }
  template <typename T,
            typename enable_if<has_read<T>::value>::type * = nullptr>
  inline bool read_single(T &x) {
    x.read();
    return true;
  }
  bool read_single(double &ref) {
    string s;
    if (!read_single(s)) return false;
    ref = std::stod(s);
    return true;
  }
  bool read_single(char &ref) {
    string s;
    if (!read_single(s) || s.size() != 1) return false;
    ref = s[0];
    return true;
  }
  template <class T>
  bool read_single(vector<T> &ref) {
    for (auto &d: ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T, class U>
  bool read_single(pair<T, U> &p) {
    return (read_single(p.first) && read_single(p.second));
  }
  template <size_t N = 0, typename T>
  void read_single_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
      auto &x = std::get<N>(t);
      read_single(x);
      read_single_tuple<N + 1>(t);
    }
  }
  template <class... T>
  bool read_single(tuple<T...> &tpl) {
    read_single_tuple(tpl);
    return true;
  }
  void read() {}
  template <class H, class... T>
  void read(H &h, T &... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE *fp) : fp(fp) {}
};

struct Printer {
  Printer(FILE *_fp) : fp(_fp) {}
  ~Printer() { flush(); }

  static constexpr size_t SIZE = 1 << 15;
  FILE *fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write(const char val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write('0');
      return;
    }
    if (val < 0) {
      write('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) { line[pos + i] = small[len - 1 - i]; }
    pos += len;
  }
  void write(const string s) {
    for (char c: s) write(c);
  }
  void write(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write(s[i]);
  }
  void write(const double x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  void write(const long double x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  template <typename T,
            typename enable_if<has_write<T>::value>::type * = nullptr>
  inline void write(T x) {
    x.write();
  }
  template <class T>
  void write(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  template <class T, class U>
  void write(const pair<T, U> val) {
    write(val.first);
    write(' ');
    write(val.second);
  }
  template <size_t N = 0, typename T>
  void write_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
      if constexpr (N > 0) { write(' '); }
      const auto x = std::get<N>(t);
      write(x);
      write_tuple<N + 1>(t);
    }
  }
  template <class... T>
  bool write(tuple<T...> tpl) {
    write_tuple(tpl);
    return true;
  }
  template <class T, size_t S>
  void write(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  void write(i128 val) {
    string s;
    bool negative = 0;
    if (val < 0) {
      negative = 1;
      val = -val;
    }
    while (val) {
      s += '0' + int(val % 10);
      val /= 10;
    }
    if (negative) s += "-";
    reverse(all(s));
    if (len(s) == 0) s = "0";
    write(s);
  }
};
Scanner scanner = Scanner(stdin);
Printer printer = Printer(stdout);
void flush() { printer.flush(); }
void print() { printer.write('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  printer.write(head);
  if (sizeof...(Tail)) printer.write(' ');
  print(forward<Tail>(tail)...);
}

void read() {}
template <class Head, class... Tail>
void read(Head &head, Tail &... tail) {
  scanner.read(head);
  read(tail...);
}
} // namespace fastio
using fastio::print;
using fastio::flush;
using fastio::read;

#define INT(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  read(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define CHAR(...)   \
  char __VA_ARGS__; \
  read(__VA_ARGS__)
#define DBL(...)      \
  double __VA_ARGS__; \
  read(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 2 "library/mod/modint.hpp"

template <int mod>
struct modint {
  int val;
  constexpr modint(ll x = 0) noexcept {
    if (0 <= x && x < mod)
      val = x;
    else {
      x %= mod;
      val = (x < 0 ? x + mod : x);
    }
  }
  bool operator<(const modint &other) const {
    return val < other.val;
  } // To use std::map
  modint &operator+=(const modint &p) {
    if ((val += p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator-=(const modint &p) {
    if ((val += mod - p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator*=(const modint &p) {
    val = (int)(1LL * val * p.val % mod);
    return *this;
  }
  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }
  modint operator-() const { return modint(-val); }
  modint operator+(const modint &p) const { return modint(*this) += p; }
  modint operator-(const modint &p) const { return modint(*this) -= p; }
  modint operator*(const modint &p) const { return modint(*this) *= p; }
  modint operator/(const modint &p) const { return modint(*this) /= p; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  modint inverse() const {
    int a = val, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b), swap(u -= t * v, v);
    }
    return modint(u);
  }
  modint pow(int64_t n) const {
    modint ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
#ifdef FASTIO
  void write() { fastio::printer.write(val); }
  void read() {
    ll x;
    fastio::scanner.read(x);
    if (x < 0 || x >= mod) x %= mod;
    if (x < 0) x += mod;
    val += x;
  }
#endif
  static constexpr int get_mod() { return mod; }
};

struct ArbitraryModInt {
  static constexpr bool is_modint = true;
  int val;
  ArbitraryModInt() : val(0) {}
  ArbitraryModInt(int64_t y)
      : val(y >= 0 ? y % get_mod()
                   : (get_mod() - (-y) % get_mod()) % get_mod()) {}
  bool operator<(const ArbitraryModInt &other) const {
    return val < other.val;
  } // To use std::map<ArbitraryModInt, T>
  static int &get_mod() {
    static int mod = 0;
    return mod;
  }
  static void set_mod(int md) { get_mod() = md; }
  ArbitraryModInt &operator+=(const ArbitraryModInt &p) {
    if ((val += p.val) >= get_mod()) val -= get_mod();
    return *this;
  }
  ArbitraryModInt &operator-=(const ArbitraryModInt &p) {
    if ((val += get_mod() - p.val) >= get_mod()) val -= get_mod();
    return *this;
  }
  ArbitraryModInt &operator*=(const ArbitraryModInt &p) {
    long long a = (long long)val * p.val;
    int xh = (int)(a >> 32), xl = (int)a, d, m;
    asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(get_mod()));
    val = m;
    return *this;
  }
  ArbitraryModInt &operator/=(const ArbitraryModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ArbitraryModInt operator-() const { return ArbitraryModInt(get_mod() - val); }
  ArbitraryModInt operator+(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) += p;
  }
  ArbitraryModInt operator-(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) -= p;
  }
  ArbitraryModInt operator*(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) *= p;
  }
  ArbitraryModInt operator/(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) /= p;
  }
  bool operator==(const ArbitraryModInt &p) const { return val == p.val; }
  bool operator!=(const ArbitraryModInt &p) const { return val != p.val; }
  ArbitraryModInt inverse() const {
    int a = val, b = get_mod(), u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b), swap(u -= t * v, v);
    }
    return ArbitraryModInt(u);
  }
  ArbitraryModInt pow(int64_t n) const {
    ArbitraryModInt ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
#ifdef FASTIO
  void write() { fastio::printer.write(val); }
  void read() { fastio::scanner.read(val); }
#endif
};

template <typename mint>
mint inv(int n) {
  static const int mod = mint::get_mod();
  static vector<mint> dat = {0, 1};
  assert(0 <= n);
  if (n >= mod) n %= mod;
  while (int(dat.size()) <= n) {
    int k = dat.size();
    auto q = (mod + k - 1) / k;
    int r = k * q - mod;
    dat.emplace_back(dat[r] * mint(q));
  }
  return dat[n];
}

template <typename mint>
mint fact(int n) {
  static const int mod = mint::get_mod();
  static vector<mint> dat = {1, 1};
  assert(0 <= n);
  if (n >= mod) return 0;
  while (int(dat.size()) <= n) {
    int k = dat.size();
    dat.emplace_back(dat[k - 1] * mint(k));
  }
  return dat[n];
}

template <typename mint>
mint fact_inv(int n) {
  static const int mod = mint::get_mod();
  static vector<mint> dat = {1, 1};
  assert(-1 <= n && n < mod);
  if (n == -1) return mint(0);
  while (int(dat.size()) <= n) {
    int k = dat.size();
    dat.emplace_back(dat[k - 1] * inv<mint>(k));
  }
  return dat[n];
}

template <class mint, class... Ts>
mint fact_invs(Ts... xs) {
  return (mint(1) * ... * fact_inv<mint>(xs));
}

template <typename mint, class Head, class... Tail>
mint multinomial(Head &&head, Tail &&... tail) {
  return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...);
}

template <typename mint>
mint C_dense(int n, int k) {
  static vvc<mint> C;
  static int H = 0, W = 0;

  auto calc = [&](int i, int j) -> mint {
    if (i == 0) return (j == 0 ? mint(1) : mint(0));
    return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0);
  };

  if (W <= k) {
    FOR(i, H) {
      C[i].resize(k + 1);
      FOR(j, W, k + 1) { C[i][j] = calc(i, j); }
    }
    W = k + 1;
  }
  if (H <= n) {
    C.resize(n + 1);
    FOR(i, H, n + 1) {
      C[i].resize(W);
      FOR(j, W) { C[i][j] = calc(i, j); }
    }
    H = n + 1;
  }
  return C[n][k];
}

template <typename mint, bool large = false, bool dense = false>
mint C(ll n, ll k) {
  assert(n >= 0);
  if (k < 0 || n < k) return 0;
  if (dense) return C_dense<mint>(n, k);
  if (!large) return fact<mint>(n) * fact_inv<mint>(k) * fact_inv<mint>(n - k);
  k = min(k, n - k);
  mint x(1);
  FOR(i, k) { x *= mint(n - i); }
  x *= fact_inv<mint>(k);
  return x;
}

template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
  assert(n >= 0);
  assert(0 <= k && k <= n);
  if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
  return mint(1) / C<mint, 1>(n, k);
}

// [x^d] (1-x) ^ {-n} の計算
template <typename mint, bool large = false, bool dense = false>
mint C_negative(ll n, ll d) {
  assert(n >= 0);
  if (d < 0) return mint(0);
  if (n == 0) { return (d == 0 ? mint(1) : mint(0)); }
  return C<mint, large, dense>(n + d - 1, d);
}

using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
using amint = ArbitraryModInt;
#line 2 "library/random/base.hpp"

u64 RNG_64() {
  static uint64_t x_
      = uint64_t(chrono::duration_cast<chrono::nanoseconds>(
                     chrono::high_resolution_clock::now().time_since_epoch())
                     .count())
        * 10150724397891781847ULL;
  x_ ^= x_ << 7;
  return x_ ^= x_ >> 9;
}

u64 RNG(u64 lim) { return RNG_64() % lim; }

ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }
#line 3 "library/ds/hashmap.hpp"

// u64 -> Val
template <typename Val, int LOG = 20>
struct HashMap {
  int N;
  u64* keys;
  Val* vals;
  vc<int> IDS;
  bitset<1 << LOG> used;
  const int shift;
  const u64 r = 11995408973635179863ULL;
  HashMap()
      : N(1 << LOG), keys(new u64[N]), vals(new Val[N]), shift(64 - __lg(N)) {}
  int hash(ll x) {
    static const u64 FIXED_RANDOM
        = std::chrono::steady_clock::now().time_since_epoch().count();
    return (u64(x + FIXED_RANDOM) * r) >> shift;
  }

  int index(const u64& key) {
    int i = 0;
    for (i = hash(key); used[i] && keys[i] != key; (i += 1) &= (N - 1)) {}
    return i;
  }

  // [] した時点で要素は作られる
  Val& operator[](const u64& key) {
    int i = index(key);
    if (!used[i]) IDS.eb(i), used[i] = 1, keys[i] = key, vals[i] = Val{};
    return vals[i];
  }

  Val get(const u64& key, Val default_value) {
    int i = index(key);
    if (!used[i]) return default_value;
    return vals[i];
  }

  bool count(const u64& key) {
    int i = index(key);
    return used[i] && keys[i] == key;
  }

  void reset() {
    for (auto&& i: IDS) used[i] = 0;
    IDS.clear();
  }

  // f(key, val)
  template <typename F>
  void enumerate_all(F f) {
    for (auto&& i: IDS) f(keys[i], vals[i]);
  }
};
#line 2 "library/poly/convolution_all.hpp"

#line 2 "library/mod/mod_inv.hpp"
// long でも大丈夫
ll mod_inv(ll val, ll mod) {
  val %= mod;
  if (val < 0) val += mod;
  ll a = val, b = mod, u = 1, v = 0, t;
  while (b > 0) {
    t = a / b;
    swap(a -= t * b, b), swap(u -= t * v, v);
  }
  if (u < 0) u += mod;
  return u;
}
#line 1 "library/poly/convolution_naive.hpp"
template <class T>
vector<T> convolution_naive(const vector<T>& a, const vector<T>& b) {
  int n = int(a.size()), m = int(b.size());
  vector<T> ans(n + m - 1);
  if (n < m) {
    FOR(j, m) FOR(i, n) ans[i + j] += a[i] * b[j];
  } else {
    FOR(i, n) FOR(j, m) ans[i + j] += a[i] * b[j];
  }
  return ans;
}
#line 2 "library/poly/ntt.hpp"

template <class mint>
struct ntt_info {
  static constexpr int bsf_constexpr(unsigned int n) {
    int x = 0;
    while (!(n & (1 << x))) x++;
    return x;
  }

  static constexpr int rank2 = bsf_constexpr(mint::get_mod() - 1);
  array<mint, rank2 + 1> root;
  array<mint, rank2 + 1> iroot;
  array<mint, max(0, rank2 - 1)> rate2;
  array<mint, max(0, rank2 - 1)> irate2;
  array<mint, max(0, rank2 - 2)> rate3;
  array<mint, max(0, rank2 - 2)> irate3;

  ntt_info() {
    int g = primitive_root(mint::get_mod());
    assert(g != -1);
    root[rank2] = mint(g).pow((mint::get_mod() - 1) >> rank2);
    iroot[rank2] = mint(1) / root[rank2];
    FOR_R(i, rank2) {
      root[i] = root[i + 1] * root[i + 1];
      iroot[i] = iroot[i + 1] * iroot[i + 1];
    }

    {
      mint prod = 1, iprod = 1;
      for (int i = 0; i <= rank2 - 2; i++) {
        rate2[i] = root[i + 2] * prod;
        irate2[i] = iroot[i + 2] * iprod;
        prod *= iroot[i + 2];
        iprod *= root[i + 2];
      }
    }
    {
      mint prod = 1, iprod = 1;
      for (int i = 0; i <= rank2 - 3; i++) {
        rate3[i] = root[i + 3] * prod;
        irate3[i] = iroot[i + 3] * iprod;
        prod *= iroot[i + 3];
        iprod *= root[i + 3];
      }
    }
  }

  constexpr int primitive_root(int m) {
    if (m == 167772161) return 3;
    if (m == 469762049) return 3;
    if (m == 754974721) return 11;
    if (m == 880803841) return 26;
    if (m == 998244353) return 3;
    if (m == 924844053) return 5;
    if (m == 1045430273) return 3;
    if (m == 1051721729) return 6;
    if (m == 1053818881) return 7;
    return -1;
  }
};

template <class mint>
void ntt(vector<mint>& a, bool inverse) {
  int n = int(a.size());
  int h = topbit(n);
  assert(n == 1 << h);
  static const ntt_info<mint> info;
  if (!inverse) {
    int len = 0; // a[i, i+(n>>len), i+2*(n>>len), ..] is transformed
    while (len < h) {
      if (h - len == 1) {
        int p = 1 << (h - len - 1);
        mint rot = 1;
        FOR(s, 1 << len) {
          int offset = s << (h - len);
          FOR(i, p) {
            auto l = a[i + offset];
            auto r = a[i + offset + p] * rot;
            a[i + offset] = l + r;
            a[i + offset + p] = l - r;
          }
          rot *= info.rate2[topbit(~s & -~s)];
        }
        len++;
      } else {
        int p = 1 << (h - len - 2);
        mint rot = 1, imag = info.root[2];
        for (int s = 0; s < (1 << len); s++) {
          mint rot2 = rot * rot;
          mint rot3 = rot2 * rot;
          int offset = s << (h - len);
          for (int i = 0; i < p; i++) {
            auto mod2 = 1ULL * mint::get_mod() * mint::get_mod();
            auto a0 = 1ULL * a[i + offset].val;
            auto a1 = 1ULL * a[i + offset + p].val * rot.val;
            auto a2 = 1ULL * a[i + offset + 2 * p].val * rot2.val;
            auto a3 = 1ULL * a[i + offset + 3 * p].val * rot3.val;
            auto a1na3imag = 1ULL * mint(a1 + mod2 - a3).val * imag.val;
            auto na2 = mod2 - a2;
            a[i + offset] = a0 + a2 + a1 + a3;
            a[i + offset + 1 * p] = a0 + a2 + (2 * mod2 - (a1 + a3));
            a[i + offset + 2 * p] = a0 + na2 + a1na3imag;
            a[i + offset + 3 * p] = a0 + na2 + (mod2 - a1na3imag);
          }
          rot *= info.rate3[topbit(~s & -~s)];
        }
        len += 2;
      }
    }
  } else {
    mint coef = mint(1) / mint(len(a));
    FOR(i, len(a)) a[i] *= coef;
    int len = h;
    while (len) {
      if (len == 1) {
        int p = 1 << (h - len);
        mint irot = 1;
        FOR(s, 1 << (len - 1)) {
          int offset = s << (h - len + 1);
          FOR(i, p) {
            auto l = a[i + offset];
            auto r = a[i + offset + p];
            a[i + offset] = l + r;
            a[i + offset + p]
                = (unsigned long long)(mint::get_mod() + l.val - r.val)
                  * irot.val;
            ;
          }
          irot *= info.irate2[topbit(~s & -~s)];
        }
        len--;
      } else {
        int p = 1 << (h - len);
        mint irot = 1, iimag = info.iroot[2];
        FOR(s, (1 << (len - 2))) {
          mint irot2 = irot * irot;
          mint irot3 = irot2 * irot;
          int offset = s << (h - len + 2);
          for (int i = 0; i < p; i++) {
            auto a0 = 1ULL * a[i + offset + 0 * p].val;
            auto a1 = 1ULL * a[i + offset + 1 * p].val;
            auto a2 = 1ULL * a[i + offset + 2 * p].val;
            auto a3 = 1ULL * a[i + offset + 3 * p].val;

            auto a2na3iimag
                = 1ULL * mint((mint::get_mod() + a2 - a3) * iimag.val).val;

            a[i + offset] = a0 + a1 + a2 + a3;
            a[i + offset + 1 * p]
                = (a0 + (mint::get_mod() - a1) + a2na3iimag) * irot.val;
            a[i + offset + 2 * p]
                = (a0 + a1 + (mint::get_mod() - a2) + (mint::get_mod() - a3))
                  * irot2.val;
            a[i + offset + 3 * p]
                = (a0 + (mint::get_mod() - a1) + (mint::get_mod() - a2na3iimag))
                  * irot3.val;
          }
          irot *= info.irate3[topbit(~s & -~s)];
        }
        len -= 2;
      }
    }
  }
}
#line 1 "library/poly/fft.hpp"
namespace CFFT {
using real = double;

struct C {
  real x, y;

  C() : x(0), y(0) {}

  C(real x, real y) : x(x), y(y) {}
  inline C operator+(const C& c) const { return C(x + c.x, y + c.y); }
  inline C operator-(const C& c) const { return C(x - c.x, y - c.y); }
  inline C operator*(const C& c) const {
    return C(x * c.x - y * c.y, x * c.y + y * c.x);
  }

  inline C conj() const { return C(x, -y); }
};

const real PI = acosl(-1);
int base = 1;
vector<C> rts = {{0, 0}, {1, 0}};
vector<int> rev = {0, 1};

void ensure_base(int nbase) {
  if (nbase <= base) return;
  rev.resize(1 << nbase);
  rts.resize(1 << nbase);
  for (int i = 0; i < (1 << nbase); i++) {
    rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
  }
  while (base < nbase) {
    real angle = PI * 2.0 / (1 << (base + 1));
    for (int i = 1 << (base - 1); i < (1 << base); i++) {
      rts[i << 1] = rts[i];
      real angle_i = angle * (2 * i + 1 - (1 << base));
      rts[(i << 1) + 1] = C(cos(angle_i), sin(angle_i));
    }
    ++base;
  }
}

void fft(vector<C>& a, int n) {
  assert((n & (n - 1)) == 0);
  int zeros = __builtin_ctz(n);
  ensure_base(zeros);
  int shift = base - zeros;
  for (int i = 0; i < n; i++) {
    if (i < (rev[i] >> shift)) { swap(a[i], a[rev[i] >> shift]); }
  }
  for (int k = 1; k < n; k <<= 1) {
    for (int i = 0; i < n; i += 2 * k) {
      for (int j = 0; j < k; j++) {
        C z = a[i + j + k] * rts[j + k];
        a[i + j + k] = a[i + j] - z;
        a[i + j] = a[i + j] + z;
      }
    }
  }
}
} // namespace CFFT
#line 7 "library/poly/convolution.hpp"

template <class mint>
vector<mint> convolution_ntt(vector<mint> a, vector<mint> b) {
  int n = int(a.size()), m = int(b.size());
  int sz = 1;
  while (sz < n + m - 1) sz *= 2;

  // sz = 2^k のときの高速化。分割統治的なやつで損しまくるので。
  if ((n + m - 3) <= sz / 2) {
    auto a_last = a.back(), b_last = b.back();
    a.pop_back(), b.pop_back();
    auto c = convolution(a, b);
    c.resize(n + m - 1);
    c[n + m - 2] = a_last * b_last;
    FOR(i, len(a)) c[i + len(b)] += a[i] * b_last;
    FOR(i, len(b)) c[i + len(a)] += b[i] * a_last;
    return c;
  }

  a.resize(sz), b.resize(sz);
  bool same = a == b;
  ntt(a, 0);
  if (same) {
    b = a;
  } else {
    ntt(b, 0);
  }
  FOR(i, sz) a[i] *= b[i];
  ntt(a, 1);
  a.resize(n + m - 1);
  return a;
}

template <typename mint>
vector<mint> convolution_garner(const vector<mint>& a, const vector<mint>& b) {
  int n = len(a), m = len(b);
  if (!n || !m) return {};
  // static const long long nttprimes[] = {754974721, 167772161, 469762049};
  static const long long nttprimes[] = {1045430273, 1051721729, 1053818881};
  using mint0 = modint<1045430273>;
  using mint1 = modint<1051721729>;
  using mint2 = modint<1053818881>;
  vc<mint0> a0(n), b0(m);
  vc<mint1> a1(n), b1(m);
  vc<mint2> a2(n), b2(m);
  FOR(i, n) a0[i] = a[i].val, a1[i] = a[i].val, a2[i] = a[i].val;
  FOR(i, m) b0[i] = b[i].val, b1[i] = b[i].val, b2[i] = b[i].val;
  auto c0 = convolution_ntt<mint0>(a0, b0);
  auto c1 = convolution_ntt<mint1>(a1, b1);
  auto c2 = convolution_ntt<mint2>(a2, b2);
  static const long long m01 = 1LL * nttprimes[0] * nttprimes[1];
  static const long long m0_inv_m1 = mint1(nttprimes[0]).inverse().val;
  static const long long m01_inv_m2 = mint2(m01).inverse().val;
  static const int mod = mint::get_mod();
  auto garner = [&](mint0 x0, mint1 x1, mint2 x2) -> mint {
    int r0 = x0.val, r1 = x1.val, r2 = x2.val;
    int v1 = (m0_inv_m1 * (r1 + nttprimes[1] - r0)) % nttprimes[1];
    auto v2 = (mint2(r2) - r0 - mint2(nttprimes[0]) * v1) * mint2(m01_inv_m2);
    return mint(r0 + 1LL * nttprimes[0] * v1 + m01 % mod * v2.val);
  };
  vc<mint> c(len(c0));
  FOR(i, len(c)) c[i] = garner(c0[i], c1[i], c2[i]);
  return c;
}

template <typename R>
vc<double> convolution_fft(const vc<R>& a, const vc<R>& b) {
  using C = CFFT::C;
  int need = (int)a.size() + (int)b.size() - 1;
  int nbase = 1;
  while ((1 << nbase) < need) nbase++;
  CFFT::ensure_base(nbase);
  int sz = 1 << nbase;
  vector<C> fa(sz);
  for (int i = 0; i < sz; i++) {
    int x = (i < (int)a.size() ? a[i] : 0);
    int y = (i < (int)b.size() ? b[i] : 0);
    fa[i] = C(x, y);
  }
  CFFT::fft(fa, sz);
  C r(0, -0.25 / (sz >> 1)), s(0, 1), t(0.5, 0);
  for (int i = 0; i <= (sz >> 1); i++) {
    int j = (sz - i) & (sz - 1);
    C z = (fa[j] * fa[j] - (fa[i] * fa[i]).conj()) * r;
    fa[j] = (fa[i] * fa[i] - (fa[j] * fa[j]).conj()) * r;
    fa[i] = z;
  }
  for (int i = 0; i < (sz >> 1); i++) {
    C A0 = (fa[i] + fa[i + (sz >> 1)]) * t;
    C A1 = (fa[i] - fa[i + (sz >> 1)]) * t * CFFT::rts[(sz >> 1) + i];
    fa[i] = A0 + A1 * s;
  }
  CFFT::fft(fa, sz >> 1);
  vector<double> ret(need);
  for (int i = 0; i < need; i++) {
    ret[i] = (i & 1 ? fa[i >> 1].y : fa[i >> 1].x);
  }
  return ret;
}

vector<ll> convolution(const vector<ll>& a, const vector<ll>& b) {
  int n = len(a), m = len(b);
  if (!n || !m) return {};
  if (min(n, m) <= 60) return convolution_naive(a, b);
  ll abs_sum_a = 0, abs_sum_b = 0;
  ll LIM = 1e15;
  FOR(i, n) abs_sum_a = min(LIM, abs_sum_a + abs(a[i]));
  FOR(i, n) abs_sum_b = min(LIM, abs_sum_b + abs(b[i]));
  if (i128(abs_sum_a) * abs_sum_b < 1e15) {
    vc<double> c = convolution_fft<ll>(a, b);
    vc<ll> res(len(c));
    FOR(i, len(c)) res[i] = ll(floor(c[i] + .5));
    return res;
  }

  static constexpr unsigned long long MOD1 = 754974721; // 2^24
  static constexpr unsigned long long MOD2 = 167772161; // 2^25
  static constexpr unsigned long long MOD3 = 469762049; // 2^26
  static constexpr unsigned long long M2M3 = MOD2 * MOD3;
  static constexpr unsigned long long M1M3 = MOD1 * MOD3;
  static constexpr unsigned long long M1M2 = MOD1 * MOD2;
  static constexpr unsigned long long M1M2M3 = MOD1 * MOD2 * MOD3;

  static const unsigned long long i1 = mod_inv(MOD2 * MOD3, MOD1);
  static const unsigned long long i2 = mod_inv(MOD1 * MOD3, MOD2);
  static const unsigned long long i3 = mod_inv(MOD1 * MOD2, MOD3);

  using mint1 = modint<MOD1>;
  using mint2 = modint<MOD2>;
  using mint3 = modint<MOD3>;

  vc<mint1> a1(n), b1(m);
  vc<mint2> a2(n), b2(m);
  vc<mint3> a3(n), b3(m);
  FOR(i, n) a1[i] = a[i], a2[i] = a[i], a3[i] = a[i];
  FOR(i, m) b1[i] = b[i], b2[i] = b[i], b3[i] = b[i];

  auto c1 = convolution_ntt<mint1>(a1, b1);
  auto c2 = convolution_ntt<mint2>(a2, b2);
  auto c3 = convolution_ntt<mint3>(a3, b3);

  vc<ll> c(n + m - 1);
  FOR(i, n + m - 1) {
    u64 x = 0;
    x += (c1[i].val * i1) % MOD1 * M2M3;
    x += (c2[i].val * i2) % MOD2 * M1M3;
    x += (c3[i].val * i3) % MOD3 * M1M2;
    ll diff = c1[i].val - ((long long)(x) % (long long)(MOD1));
    if (diff < 0) diff += MOD1;
    static constexpr unsigned long long offset[5]
        = {0, 0, M1M2M3, 2 * M1M2M3, 3 * M1M2M3};
    x -= offset[diff % 5];
    c[i] = x;
  }
  return c;
}

template <typename mint>
enable_if_t<is_same<mint, modint998>::value, vc<mint>> convolution(
    const vc<mint>& a, const vc<mint>& b) {
  int n = len(a), m = len(b);
  if (!n || !m) return {};
  if (min(n, m) <= 60) return convolution_naive(a, b);
  return convolution_ntt(a, b);
}

template <typename mint>
enable_if_t<!is_same<mint, modint998>::value, vc<mint>> convolution(
    const vc<mint>& a, const vc<mint>& b) {
  int n = len(a), m = len(b);
  if (!n || !m) return {};
  if (min(n, m) <= 2000) return convolution_naive(a, b);
  return convolution_garner(a, b);
}
#line 4 "library/poly/convolution_all.hpp"

template <typename T>
vc<T> convolution_all(vc<vc<T>>& polys) {
  if (len(polys) == 0) return {T(1)};
  while (1) {
    int n = len(polys);
    if (n == 1) break;
    int m = ceil(n, 2);
    FOR(i, m) {
      if (2 * i + 1 == n) {
        polys[i] = polys[2 * i];
      } else {
        polys[i] = convolution(polys[2 * i], polys[2 * i + 1]);
      }
    }
    polys.resize(m);
  }
  return polys[0];
}
#line 6 "main.cpp"

using mint = modint<1'000'000'009>;
using poly = vc<mint>;

const int LIM = 10'000;

mint evaluate(poly& f, mint x) {
  mint fx = 0;
  mint pow = 1;
  FOR(i, len(f)) {
    fx += f[i] * pow;
    pow *= x;
  }
  return fx;
}

vc<mint> multipoint_interpolate_naive(vc<mint> x, vc<mint> y) {
  int n = len(x);
  poly F(n);
  poly g = {1};
  FOR(i, n) {
    mint now = evaluate(F, x[i]);
    mint a = evaluate(g, x[i]);
    a = (y[i] - now) / a;
    FOR(j, len(g)) { F[j] += g[j] * a; }
    g.insert(g.begin(), mint(0));
    FOR(j, len(g) - 1) g[j] -= g[j + 1] * x[i];
  }
  return F;
}

// M 次多項式 F に対して G(x)=x^MF(x+1/x)
poly F_to_G(poly F) {
  if (F.empty()) return {};
  int deg = len(F) - 1;
  assert(deg >= 0);
  if (deg == 0) { return {F[0]}; }
  int m = deg / 2;
  poly F1 = F_to_G({F.begin(), F.begin() + m + 1});
  poly F2 = F_to_G({F.begin() + m + 1, F.end()});
  // (1+x^2)^{m+1} をかける
  poly g(m + m + 3);
  FOR(i, m + 2) g[2 * i] = C<mint>(m + 1, i);
  F2 = convolution(g, F2);
  int off = (len(F2) - len(F1)) / 2;
  FOR(i, len(F1)) F2[off + i] += F1[i];
  return F2;
}

vc<mint> solve_even(vc<mint> X, vc<mint> Y, int ODD) {
  static HashMap<int, 12> MP;
  ll N = len(X);
  vc<mint> Y0;
  {
    // x = 0 のやつ
    vc<mint> X1, Y1;
    FOR(i, N) {
      if (X[i] == mint(0)) {
        Y0.eb(Y[i]);
      } else {
        X1.eb(X[i]);
        Y1.eb(Y[i]);
      }
    }
    swap(X, X1);
    swap(Y, Y1);
  }
  N = len(X);
  vc<mint> INV_X(N);
  FOR(i, N) INV_X[i] = X[i].inverse();

  int mx = LIM / 2 + 10;
  FOR(i, N) Y[i] /= X[i].pow(mx);

  FOR_R(M, mx) {
    // Y[i] が Y[i] / X[i]^M である状態を維持する
    FOR(i, N) Y[i] *= X[i];

    if (2 * M + ODD > LIM) continue;

    MP.reset();
    bool ok = 1;
    FOR(i, N) {
      mint x = X[i] + INV_X[i], y = Y[i];
      if (MP.count(x.val) && MP[x.val] != y.val) ok = 0;
      MP[x.val] = y.val;
    }
    if (!ok) continue;
    vc<mint> XX, YY;
    MP.enumerate_all([&](int a, int b) -> void { XX.eb(a), YY.eb(b); });
    auto F0 = multipoint_interpolate_naive(XX, YY);
    while (len(F0) && F0.back() == mint(0)) F0.pop_back();
    int deg = len(F0) - 1;

    if (deg < M) {
      if (len(XX) > M) continue;
      // 最高次の係数制約
      mint c = (Y0.empty() ? mint(1) : Y0[0]);
      vc<poly> polys;
      for (auto&& a: XX) { polys.eb(poly{-a, mint(1)}); }

      poly F = convolution_all(polys);
      for (auto&& x: F) x *= c;

      int a = M + 1 - len(F);
      // x^aF + F0
      poly G = F_to_G(F);
      poly g(a + a + 1);
      FOR(i, a + 1) g[2 * i] = C<mint>(a, i);
      G = convolution(G, g);
      poly G0 = F_to_G(F0);
      poly res(M + M + 1);
      int off = (len(res) - len(G0)) / 2;
      FOR(i, len(G0)) G[off + i] += G0[i];
      return G;
      /*
      {
        // 次数調整
        reverse(all(F));
        while (len(F) != M + 1) { F.eb(mint(0)); }
        reverse(all(F));
      }
      assert(len(F) == M + 1);
      for (auto&& x: F) x *= c;
      // F0 を足す
      FOR(i, len(F0)) F[i] += F0[i];
      // FOR(i, N) { assert(evaluate(F, X[i] + INV_X[i]) == Y[i]); }
      return F_to_G(F);
      */
    }

    if (deg > M) continue;
    if (deg == M) {
      if (!Y0.empty() && Y0[0] != F0[deg]) continue;
      return F_to_G(F0);
    }
  }
  return {};
}

void solve() {
  LL(N);
  vc<mint> X(N), Y(N);
  FOR(i, N) read(X[i]);
  FOR(i, N) read(Y[i]);

  FOR(i, N) {
    if (X[i] == mint(0) && Y[i] == mint(0)) return print(-1);
  }

  vc<mint> X0 = X, Y0 = Y;

  auto check = [&](poly f) -> void {
    int deg = len(f) - 1;
    // assert(0 <= deg && deg <= 10000);
    assert(f[deg] != mint(0));
    // FOR(i, deg + 1) assert(f[i] == f[deg - i]);
    FOR(i, N) {
      mint x = X0[i], y = Y0[i];
      mint fx = mint(0), pow = mint(1);
      FOR(j, len(f)) {
        fx += f[j] * pow;
        pow *= x;
      }
      // if (x != mint(0) && x != mint(-1)) { assert(fx == y); }
      assert(fx == y);
    }
  };

  auto out = [&](poly f) -> void {
    check(f);
    int deg = len(f) - 1;
    print(deg);
    print(f);
  };

  poly F = solve_even(X, Y, 0);

  if (!F.empty()) { return out(F); };

  // x+1 で割る
  bool ok = 1;
  {
    vc<mint> X1, Y1;
    FOR(i, N) {
      if (X[i] + mint(1) == mint(0)) {
        if (Y[i] != mint(0)) ok = 0;
      } else {
        X1.eb(X[i]);
        Y1.eb(Y[i] / (X[i] + mint(1)));
      }
    }
    swap(X1, X);
    swap(Y1, Y);
  }
  if (!ok) { return print(-1); }
  F = solve_even(X, Y, 1);
  if (F.empty()) return print(-1);
  // 1+x をかける
  F.eb(mint(0));
  FOR_R(i, len(F) - 1) F[i + 1] += F[i];
  return out(F);
}

void test() {
  poly f = {2, 3};
  print(F_to_G(f));
}

signed main() {
  INT(T);
  FOR(T) solve();
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 6ms
memory: 3924kb

input:

8
2
0 1
2 4
3
0 1 2
2 10 36
4
0 1 2 3
1 4 9 16
5
0 1 2 3 4
1 25 961 14641 116281
2
2 500000005
5 375000004
2
2 500000005
5 375000004
2
2 500000005
1 2
3
2 500000005 3
5 375000004 10

output:

10000
2 1000000005 10000 999980013 24995000 950030005 641669631 766630760 855779320 521810627 94688849 288811684 328466086 54256153 622802680 700138505 706719163 886423196 326892219 459792384 51905035 436397555 818738400 926125672 390486740 292900866 595987820 515123512 585087976 314700554 883241480...

result:

ok OK (8 test cases)

Test #2:

score: 0
Accepted
time: 94ms
memory: 3936kb

input:

10
100
24820 26839 18512 6097 25046 22372 21548 2359 17721 9732 16436 12710 14995 4112 17855 28268 28129 13501 23470 16561 8633 29875 13119 10835 15842 14515 5588 10553 28603 3849 12379 17065 15155 15079 26029 3003 2878 29555 3609 8886 2841 17696 9648 4533 5924 12557 25988 29061 26075 28447 28620 20...

output:

10000
1 485418561 47261373 589953978 524468134 497294391 876900321 125849010 625701051 572558373 813843450 851716638 849490864 607272158 777312757 268781058 263674081 499448620 709202953 481292616 615730572 281156470 527036818 620408495 719169150 766244334 54426446 37348984 8498477 548465367 4408456...

result:

ok OK (10 test cases)

Test #3:

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

input:

1
1000
112 16069 28329 8759 23521 1674 11755 9574 19846 5769 27729 17604 3648 29441 25349 24311 6088 2549 6437 16310 25464 25775 20988 21334 3451 1098 26971 3856 28015 24136 18147 24690 4690 4517 14412 29017 14675 5027 18071 4428 29328 28568 12161 2780 23653 21472 21227 23968 1331 24977 7243 13552 6...

output:

10000
1 510401453 999474454 424331461 715359153 201139225 392995176 646981075 690535887 642658394 414670779 875524425 204993929 149874484 440831086 917178075 745275209 550466387 308968342 166877651 963420656 600587507 786621385 309561256 897044188 185254492 135841387 494359606 528327221 564205975 36...

result:

ok OK (1 test case)

Test #4:

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

input:

21
8
1000000008 191950673 311042534 341446923 351508511 730849637 837221839 949983050
2 199758730 296525790 620719636 271569769 48989015 768611306 77253955
8
1 6208459 29989762 187741303 265062278 393002943 957915451 986759042
2 603327752 901822821 349826936 933716294 123962049 672761843 702453404
8...

output:

8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
8
1 0 0 0 0 0 0 0 1
...

result:

ok OK (21 test cases)

Test #5:

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

input:

21
8
1000000008 82536156 95733833 173997609 176779824 454444312 524861364 586834996
4 841461190 384072747 954440743 152490383 894790857 441089967 851188211
8
1 62386922 117616238 344901582 692317472 798339321 934650757 967500526
4 923589217 91616771 328945919 250367604 465360899 562911768 673536418
...

output:

8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
2 0 0 0 0 0 0 0 2
8
1 745551825 433482217 754346262 592338039 754346262 433482217 745551825 1
8
2 0 0 0 0 0 0 0 2
8
1 ...

result:

ok OK (21 test cases)

Test #6:

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

input:

21
9
72520483 109296160 328830012 427629800 496439117 517407888 723526448 875376334 984205010
513501309 405430695 97038420 80044690 244607478 420952403 730491956 655670564 934113242
9
1000000008 1 196696216 367187687 520201124 575456207 634588206 768006032 938587173
0 2 305160038 629977990 316645777...

output:

9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 0 0 0 1
9
1 0 0 0 0 0 ...

result:

ok OK (21 test cases)

Test #7:

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

input:

21
9
7776991 170135976 184357477 364912922 393159207 671848154 694727065 726096468 807558271
931408489 76229428 359286772 482810970 983371544 900415283 988630700 476855584 692102868
9
1000000008 1 254616697 350933937 613951686 792090796 806204674 896604470 996266271
0 4 296124300 133457045 889008814...

output:

9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
2 0 0 0 0 0 0 0 0 2
9
1 704272955 206622628 292780706 947166666 947166666 292780706 206622628 704272...

result:

ok OK (21 test cases)

Test #8:

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

input:

21
8
1000000008 293188747 506560951 728885372 795956429 838708555 880755953 954756300
1 931650696 717763978 59630926 173745195 741697269 899703391 234180638
8
1 46322566 407158342 509723817 636040242 738500416 759476271 948754709
25 216101899 119160932 343194015 57776340 157262836 276807561 33982633...

output:

8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
8
1 2 3 4 5 4 3 2 1
...

result:

ok OK (21 test cases)

Test #9:

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

input:

21
9
75218911 90366076 119101189 194246800 350541227 377200962 818012261 895921660 966585262
732955481 335776396 765729084 902489414 875573484 526286992 675327718 219549932 52753284
9
1000000008 1 121073903 135154924 206002108 693217175 709348851 800428289 922910175
0 30 110846868 369125846 78199011...

output:

9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 4 3 2 1
9
1 2 3 4 5 5 ...

result:

ok OK (21 test cases)

Test #10:

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

input:

21
10
1000000008 12260195 80754602 163716464 312829272 391611827 673741746 728563133 811628297 911803655
0 235646491 746092480 793242180 563675433 190413403 995430294 304276112 911389010 347436328
10
1 18892100 71240811 234644042 405445374 537145743 553798351 572060490 726412557 875107448
36 5419823...

output:

10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
10
1 2 3 4 5 6 5 4 3 2 1
...

result:

ok OK (21 test cases)

Test #11:

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

input:

21
15
102902010 104440499 141407938 254801315 302108881 375503505 483498247 569424584 631076513 674425009 710414727 748037505 787597696 897754981 913961979
750445007 723764181 522261770 384970598 466582584 399445938 304490242 178761561 97731177 711994375 711199040 109300424 225657734 328363283 70380...

output:

15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33
15
33 ...

result:

ok OK (21 test cases)

Test #12:

score: 0
Accepted
time: 33ms
memory: 3616kb

input:

21
15
190238676 408903599 473934421 488621309 500829135 684814169 779979654 813377310 866962260 874120900 882901969 929880722 939256395 956209677 995016475
508631129 882709950 185145270 713649239 983567479 998524204 67708788 859291 999492696 130232703 891966111 441494490 332533393 703135760 64268444...

output:

15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 ...

result:

ok OK (21 test cases)

Test #13:

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

input:

21
19
26294376 70967317 135772333 163164758 190196450 190331407 263742305 289352143 294421555 384429498 404563902 421898751 501143739 558923946 663294565 687319026 754424225 840450575 911028598
260487108 14726161 703228508 619949324 417344016 544228071 953555078 345998205 557232429 191999681 4600517...

output:

19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96
19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96
19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96
19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96
19
96 23 54 68 33 62 84 100 26 18 18 26 ...

result:

ok OK (21 test cases)

Test #14:

score: 0
Accepted
time: 36ms
memory: 3680kb

input:

21
19
65433256 203120539 230619032 242339653 306408928 319892667 358753761 406955804 456020246 568215116 658002035 667809083 713920687 758560518 792203516 826915826 868910207 947222195 979951831
710093141 609738169 294821300 319884586 559809243 118163813 202242806 53046643 383830818 669518255 473578...

output:

19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 ...

result:

ok OK (21 test cases)

Test #15:

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

input:

21
19
94730190 98406141 117177150 151885244 178905728 222257031 349187661 384666078 386234223 455425437 470266682 722168666 809818898 835948150 860749403 917499921 934399177 956526573 989637011
303082625 162132429 408192664 585973108 271970371 500211566 129010096 685239539 653965708 393652022 994078...

output:

19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 9...

result:

ok OK (21 test cases)

Test #16:

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

input:

1
1000
1000000008 1163314 1725881 1859188 1927255 4342530 4578730 4746103 5123392 5506632 6230591 7566874 8086831 8637758 8890521 9139570 9965029 10373127 11912148 12953170 13042845 14260540 14474386 14647027 16719219 17143558 17206396 17598422 18621675 19116034 20547451 20737458 20849209 21344486 2...

output:

1000
79575517 935081668 622423990 636314169 144962938 141608677 45549202 341682233 778977652 453994042 201348892 869626487 36301614 222442438 810013863 682259528 307591988 74561654 865182948 602546620 503622727 592141979 822723137 146617557 257332795 208689416 598623744 418635055 602842188 790204312...

result:

ok OK (1 test case)

Test #17:

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

input:

1
1000
1000000008 119871 1389570 2707693 3843539 4475280 5503109 5549495 6795010 6881337 7004323 7784996 8817035 10260341 11888079 13315748 13575297 15614332 16009588 16062325 18552071 21109298 22056617 22934163 23508035 26281837 26986091 28233931 30097845 30596645 31675568 31809106 33878728 3514484...

output:

1000
257920431 967312002 754148659 599813599 198657247 4255073 205357317 162913793 13556407 971226952 712695563 911842439 13175537 473968002 101763748 450088031 263579202 561428812 121431558 219709408 20961014 664435919 698890141 769188921 150065990 731810438 847809296 773977042 752404641 279478033 ...

result:

ok OK (1 test case)

Test #18:

score: 0
Accepted
time: 58ms
memory: 3692kb

input:

1
1000
1000000008 995271 1043526 1569741 1930761 2373180 2655267 2894638 2972099 3570020 3727464 5293902 5459186 5592012 7143746 8038917 8302839 8742904 9597001 10871411 12265577 13229016 13866685 14178506 15546918 15659624 16069122 16352870 18441557 18941292 20438984 20579817 21493813 21999600 2332...

output:

1000
501255971 151947671 15379387 40432587 410380585 932847170 103225974 997584739 699852020 81269848 791519323 291398574 853646708 115657125 950691825 189433956 345218295 288555342 72048515 285844713 681878453 294292577 8612288 639872842 31042508 295420878 917443062 364745349 285266528 384039334 77...

result:

ok OK (1 test case)

Test #19:

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

input:

1
1000
1000000008 1930327 3748583 4732516 5761677 6524408 6953970 7673074 10215389 11599237 12891198 13367997 13443691 13480811 13814537 14242925 15448701 16851660 17860191 18576284 20750503 21287239 21772850 21931267 24200127 25706412 26674484 27001628 29416809 29417481 29696933 31919132 32361009 3...

output:

1001
1 486572860 294479866 130023980 202947638 197815123 355158084 252065765 729051871 859325892 988802640 429927433 512426882 975236440 710089442 430240252 856663058 61882684 776771433 150421007 306874215 412648916 91317778 131866287 508211129 944477644 116678199 156036661 229874960 453031737 11655...

result:

ok OK (1 test case)

Test #20:

score: 0
Accepted
time: 114ms
memory: 3784kb

input:

1
1000
1000000008 19655 1057867 1964843 2826271 6349908 7186978 9276122 11144062 11910084 12130477 13712767 15211331 15439577 17431103 22303206 22618031 23229606 24087435 25793057 27118960 28967939 29863766 32133950 32224454 32229860 32973855 34256429 35288465 35428105 37461019 37639895 38513911 385...

output:

1001
1 759973984 498891287 473426386 176454837 966218053 356109743 886283851 372517913 704131304 101763227 290398885 564453524 701036684 935075147 374323901 787485312 28279382 598991748 691564480 645881832 772214536 94407034 491600342 304656404 559749300 102391892 973954148 977678466 296567378 91489...

result:

ok OK (1 test case)

Test #21:

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

input:

1
1000
1000000008 2123473 2337497 2647785 2714138 4307445 4578311 5599173 6100322 7262671 8156005 8717048 9035468 9622351 10544976 11210969 11400533 12274760 14890507 14904020 15890200 16450429 16952722 17869294 18432568 19673198 20047804 23509418 25269660 25383779 25455144 27481698 29629773 2975078...

output:

1001
1 292399259 59335213 332007268 865065777 801886116 83277824 213541879 742457275 950051591 389972758 490588170 500625980 372244906 675179679 647905891 763158337 543238509 840332696 466157702 995550004 97844310 860977499 271726749 722755128 539603994 582829150 978767602 776050455 58468574 2655172...

result:

ok OK (1 test case)

Test #22:

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

input:

1
1000
1000000008 1 979543 1099673 2311834 2392336 3331761 5232856 5668529 5853303 8253217 9412317 10576558 12212409 12972885 13090359 13401142 14359459 14936104 15009169 15325450 15889761 17492445 18234479 18367419 19877788 20196006 21459330 21965618 22568003 24705386 24908023 27175324 27645592 280...

output:

1000
875040106 280699124 387142789 156289401 113119764 231698527 568134600 201705284 342325462 637892505 284662306 112090695 881317853 253818873 428126974 64848144 666946232 16046000 956700128 133611760 712665170 169086466 738922597 123194460 643106545 225300668 53441513 682019016 230413433 44626739...

result:

ok OK (1 test case)

Test #23:

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

input:

1
1000
1000000008 1 4002897 4074300 7807719 9221820 10062677 10247707 11793051 12076502 12383773 12850315 12909440 13699665 14669717 17364634 18334687 18488120 19251198 19327484 19351685 21227522 21473157 22536795 23445221 24786248 25276279 25516212 28760808 28997973 30065464 30458276 30865599 31228...

output:

1000
677490484 34172339 425915220 133272717 525533229 497270494 69060070 728759223 494156373 365238799 88340994 210682693 798755901 542372007 639584015 837271699 331303174 949443697 33441551 974757662 957173392 470387 508380030 823350231 934835917 767377046 942616254 653535532 114963770 69252437 578...

result:

ok OK (1 test case)

Test #24:

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

input:

1
1000
1000000008 1 1020644 5382771 5719073 6493197 7113938 7716494 9076935 9900713 12520522 13643863 14906033 15306765 15520944 16541433 17389045 18586011 19460259 20441544 21264034 21593776 23108118 25344994 26032018 29105874 29507267 31940778 32334657 32350077 32372905 33037067 33369145 34839406 ...

output:

1000
324400949 138285803 462932276 949332334 799317485 110578698 32991752 988658071 114579580 156197354 845254329 122647862 127745259 196929514 618844963 457937567 610323286 94294405 999013365 98901407 38224877 901618608 568697948 449088553 151609376 6909982 890319078 117709970 123579938 19357588 27...

result:

ok OK (1 test case)

Test #25:

score: 0
Accepted
time: 111ms
memory: 3656kb

input:

1
1000
459429 699878 1274783 1464867 2263572 2791534 3527960 4706024 6945270 7888629 8613660 8722107 8742188 9003703 10916249 11336542 12438667 12708870 14332440 16686112 16896938 17257014 19457577 20651141 22022600 23446548 24162091 25735242 27706189 28900858 29566281 31433967 32485062 32890720 330...

output:

1263
1 919570883 422810246 900131191 812762914 310791807 313519574 757680204 214608535 145963681 68122942 662275191 418428737 306933295 116929493 257373792 470725047 516733120 957196244 418849367 907346892 727978891 496710594 276736647 126777450 398468010 938214823 178094808 809313658 857095272 6765...

result:

ok OK (1 test case)

Test #26:

score: 0
Accepted
time: 107ms
memory: 3736kb

input:

1
1000
539582 587787 823210 1838290 2968320 4763018 5452385 5759375 7499639 9268735 10059629 10426675 11252932 12083704 12772856 13255096 15256882 15398881 16556597 17094215 17824573 18058249 19298525 26461962 26540463 27208624 28878283 29337698 29508878 29750225 29816065 30030072 30700382 32937761 ...

output:

1107
1 992727822 573686500 220039640 603760866 670176240 250137327 489053023 396813259 278364161 423766507 195679481 680975586 809478134 630373483 549842084 337259113 991030928 700718611 28655169 290717221 871175625 746192225 201633254 35190533 866257586 950566377 320328045 217255405 943243709 85054...

result:

ok OK (1 test case)

Test #27:

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

input:

1
1000
1400971 1525412 1895243 2886037 2935228 2953133 3648417 3848336 5149240 5665376 5805252 7627425 8262327 10896987 12584489 12609031 12775145 14176272 14403849 15101570 16731600 17493993 21095811 21269540 21865611 21996684 24659823 25151457 25644882 25843765 26226417 26507726 27698139 28396383 ...

output:

1461
1 669161835 651461950 561608260 645457957 967318031 588470876 330305413 391810670 15868684 992486107 589817462 418414150 972081637 849550575 129220453 774477360 123594758 647922665 483768849 694854020 520694308 914834748 543066656 58818843 445862864 233407658 960449985 258318147 437383374 20047...

result:

ok OK (1 test case)

Test #28:

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

input:

1
1000
18257 2517136 2754522 3446997 3572234 3605609 4467547 4867328 5022683 6204397 7174270 8070365 8480158 9091902 10467727 11532430 11927584 13251677 13286612 13960248 14528228 14753170 15245960 16201420 17810446 17901664 19852933 19925622 20407743 20582958 20617713 21204188 21668313 22997268 234...

output:

1286
1 25033533 167526489 328538675 134982109 213815470 611127067 689040716 488181641 785508316 176063735 899623480 136407872 164484144 81714583 306622021 182011929 734300649 495265650 355309830 496460191 178987262 488941731 65576082 536347567 582301122 676950379 891378182 246190316 813163288 570837...

result:

ok OK (1 test case)

Test #29:

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

input:

1
1000
996737 1536175 3101070 3644382 5170720 5787576 6266386 9714384 9834864 10495517 14090608 14642514 15311125 15793968 16310838 17244201 17316962 17585111 18479026 19707052 19839248 20025852 21127374 21714531 22326012 22524961 22528119 23538749 24774379 33421876 34041195 34456463 34531389 369802...

output:

1998
1 957388920 416243923 340170057 29852596 873379682 691730089 293338794 396588600 473538420 271244137 50760546 888421639 608249942 515668772 468076516 352628107 928093964 955472966 784692885 68123805 421153271 385006582 45227122 646135263 359808374 382022749 19498542 383205315 917838300 72058237...

result:

ok OK (1 test case)

Test #30:

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

input:

1
1000
782165 818688 2385162 2504686 3746632 3810165 4398857 4905098 6244695 6489354 7213334 7653067 8091494 8142002 9238224 9638275 10692110 11290778 12619875 12886372 13068826 13740051 14689310 15762919 16498511 18469126 19480024 20070327 20364643 20406003 21855872 22034565 22721542 24506788 25382...

output:

5068
1 29714925 978669888 306792839 206839350 646760926 887106211 512665155 765529233 382336431 536421343 644593584 586428407 388410480 374973153 715741994 492179518 963599206 512622522 987961382 213191166 77541429 776869330 173434439 831752050 942460227 502426808 263871659 456104446 504830955 97747...

result:

ok OK (1 test case)

Test #31:

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

input:

1
1000
1000000008 1 65747 867548 2909364 3566380 4307576 6281702 6849581 9004452 9421540 9652914 10782791 10827322 12408129 13657581 14320403 14966315 15286154 16077116 16306015 17456970 18103823 18576529 19640517 20120108 20974376 21146685 21691051 23155596 23483018 23795267 24773978 25191064 25465...

output:

3818
1 704880737 11870398 102820118 554619304 10023875 493633384 852387364 656695883 446878971 620827835 26893591 675994203 987620798 754697415 648144056 137521745 486644222 971966205 981602431 967049407 488206297 153682798 87398594 460776396 547969632 742113864 427788592 487137143 144018460 2722882...

result:

ok OK (1 test case)

Test #32:

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

input:

1
1000
1000000008 1 155415 1120795 5075090 5177841 5400240 5939545 6126832 6686481 6742156 7555095 8548302 8719620 8760748 9630584 10548298 11929056 11963247 13342890 13462765 14568520 14853846 15509357 15642103 19105061 19119816 22065447 23896409 25071710 25850281 26198108 27466856 29576775 2973926...

output:

1950
1 464230551 782042991 765551978 845292115 273547019 253969464 104668092 824553223 308810511 89215375 257229817 985051231 55376392 590180201 985743925 409929812 457338882 697214009 550294620 507076868 798278283 673301166 625041122 836747494 546275229 821964492 377849653 46996446 17533877 4754984...

result:

ok OK (1 test case)

Test #33:

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

input:

1
1000
1000000008 1 3794823 3990160 4069010 7200609 7545237 7625903 7650923 7733012 8150039 10453187 11194942 11992704 12565148 12672036 14197425 14297429 14923010 15319779 15437211 16212886 17214909 19584436 19709541 19803867 20615123 20736540 21014631 22135416 22185505 22580462 22672626 23621938 2...

output:

5832
1 533615393 352373631 898270674 48104921 466577483 849662471 635369992 376536874 206304107 361543117 930491935 597699296 779687171 381687224 221453910 560908411 287767881 374397986 924994086 812126237 980704782 805331148 334804672 435617824 8820817 421298874 689777201 149836410 934970524 583840...

result:

ok OK (1 test case)

Test #34:

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

input:

10
100
2293126 5942420 6337941 13099309 15116089 17067398 29529174 33256334 41013027 44923450 45673733 49287672 55640824 74354927 89743825 113199983 113795966 115263356 115429622 123843442 124728214 143038491 148791867 150711496 154560895 182479530 183537789 186924669 211790168 215889394 219573024 2...

output:

9997
1 403086633 82218150 264337574 529305784 628150078 183028046 307649257 215481512 966376351 95176862 72516612 270099790 794802145 83186469 240726185 648750272 299354202 182031153 138162843 64744518 197745372 243055108 226780033 107970744 936422887 223132122 204101686 726850759 992027682 22528479...

result:

ok OK (10 test cases)

Test #35:

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

input:

1
1000
1000000008 1 608809 2224418 2326580 2581597 2695175 4257301 4479801 4799707 5130361 5204849 6780675 6896748 7061506 7644954 7961444 8003206 8027106 9508105 9821035 10575547 10789292 10912576 12658630 14498860 15393382 15512131 15681489 16648049 16784819 17598541 18724939 19801366 20241696 204...

output:

10000
1 616337833 165395405 764401410 903102352 204430900 273168337 985975910 491983721 183697132 701263712 189637244 738822226 940869768 514974141 468234641 992125065 556951099 353666803 549381730 349420877 304134721 316456725 842204137 707632215 411567672 561436867 302725121 924467012 616159830 42...

result:

ok OK (1 test case)

Test #36:

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

input:

42
1
0
0
5
0 1 2 3 4
0 1 2 3 4
17
1000000008 89972839 143164456 150216222 375988435 396176433 406913122 480521943 498414429 524078486 542182493 594307752 654089635 712922007 721980374 778983440 846984859
357907157 200159115 60068034 155124844 775922328 419112157 111254958 90487512 492415083 43233847...

output:

-1
-1
3584
1 83103149 262361968 530583818 451156913 282313437 936145143 555507602 984093675 967265062 989643201 538791898 573687021 991025055 478542832 739173912 398495852 709191016 407202751 721005561 186997734 505476507 381296045 274255431 444901594 935275931 159704175 492610383 954729998 33273523...

result:

ok OK (42 test cases)

Test #37:

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

input:

1
1000
1000000008 315952 463447 2030731 2235229 2753764 3129061 3763222 3925015 4922414 7349688 7504468 8267482 8342770 9522784 10292190 11241711 12053758 12295998 13049516 13248404 13421074 14366482 14831105 14950327 16223781 17603183 18455523 18929019 19499405 21298766 21608709 21877637 22134500 2...

output:

-1

result:

ok OK (1 test case)

Test #38:

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

input:

1
1000
0 1 64138 327873 516439 1707007 1945928 2469231 3176639 4190304 5097280 5425765 6419611 6730124 6813712 7602054 8033670 8520720 8567066 9599309 10336833 11624583 11913593 12049732 13811566 15781789 16151933 17586478 17682766 19333296 19400349 19450249 19510196 20377666 20933571 21235664 21882...

output:

-1

result:

ok OK (1 test case)

Test #39:

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

input:

1
1000
464961 749361 1468292 1672179 1968878 2843988 3670283 6114180 6187520 6324060 7206578 7916729 8927862 9080856 9593491 10586704 10720120 11102204 11498377 11567165 13225984 14596828 14628491 15662570 15869464 16105087 16563159 17177119 17905392 18353534 19022467 19265140 22843311 23680419 2513...

output:

-1

result:

ok OK (1 test case)

Test #40:

score: 0
Accepted
time: 95ms
memory: 3704kb

input:

1
1000
2 500000005 3 666666673 4 750000007 5 200000002 6 833333341 7 857142865 8 875000008 9 888888897 10 100000001 11 363636367 12 916666675 13 615384621 14 928571437 15 733333340 16 437500004 17 58823530 18 944444453 19 368421056 20 550000005 21 952380961 22 681818188 23 826086964 24 958333342 25 ...

output:

-1

result:

ok OK (1 test case)

Test #41:

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

input:

1
1000
2 500000005 3 666666673 4 750000007 5 200000002 6 833333341 7 857142865 8 875000008 9 888888897 10 100000001 11 363636367 12 916666675 13 615384621 14 928571437 15 733333340 16 437500004 17 58823530 18 944444453 19 368421056 20 550000005 21 952380961 22 681818188 23 826086964 24 958333342 25 ...

output:

-1

result:

ok OK (1 test case)

Test #42:

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

input:

1
1000
2 500000005 3 666666673 4 750000007 5 200000002 6 833333341 7 857142865 8 875000008 9 888888897 10 100000001 11 363636367 12 916666675 13 615384621 14 928571437 15 733333340 16 437500004 17 58823530 18 944444453 19 368421056 20 550000005 21 952380961 22 681818188 23 826086964 24 958333342 25 ...

output:

-1

result:

ok OK (1 test case)

Test #43:

score: 0
Accepted
time: 91ms
memory: 3548kb

input:

1
1000
2 500000005 3 666666673 4 750000007 5 200000002 6 833333341 7 857142865 8 875000008 9 888888897 10 100000001 11 363636367 12 916666675 13 615384621 14 928571437 15 733333340 16 437500004 17 58823530 18 944444453 19 368421056 20 550000005 21 952380961 22 681818188 23 826086964 24 958333342 25 ...

output:

-1

result:

ok OK (1 test case)

Test #44:

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

input:

25
35
15005825 35302900 79331670 96289428 115381398 136247216 185087831 192250338 229084603 237034597 312599432 431551491 463330573 469754533 500992688 529481034 535673813 540179374 544174469 561216551 616249357 681777421 703827282 723637712 744737153 774301659 780468679 784852730 817657942 84846648...

output:

9998
1 430987930 298239874 822150328 358279225 5685830 556261810 321488329 351009416 214249371 914615676 194390023 760018607 860667776 802654484 131357462 79732593 850803025 298222640 499129266 592507497 301915440 503705753 558721914 842721052 713365600 597914515 107454472 617785138 90295300 5602889...

result:

ok OK (25 test cases)

Test #45:

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

input:

1
1000
512995 673429 2517134 3126968 3975094 4035899 4707612 6633424 8319164 9306333 9842431 10955294 11540175 12018118 15445423 15941025 16204954 16297641 17861655 21184588 21465421 23173707 25825040 26058606 27892502 29153788 30028535 30473453 31277472 31606620 31844694 33708849 34006101 35014115 ...

output:

9996
1 524399779 246047945 924222104 658949869 739864817 340987697 703066764 644793915 356035547 867344452 791280529 472440979 151203104 54536301 230420207 164897921 297504201 692700954 854228925 568584198 257267142 912708627 114808803 361663149 839919094 840326039 697032497 494993281 107433197 1801...

result:

ok OK (1 test case)

Test #46:

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

input:

1
1000
351793 859041 1395307 2480430 2899199 2937592 4448687 4953957 5880016 6562890 9150507 9406949 9528307 9593976 10169417 10716000 11088660 12645474 14983122 16417899 17422872 17892227 18437295 18801714 18873667 19572980 20539615 22310670 23396125 23759313 23789911 23843637 24091595 25321776 261...

output:

9999
1 664769197 97721856 959507848 908696968 3901016 777174171 68104572 177509653 950405417 979720816 661232486 566477855 192846647 978861103 656010011 773388770 10021669 572596017 233864800 8770794 462344955 449287945 430256459 332532712 647331962 906950466 720044985 957223503 100377193 685499147 ...

result:

ok OK (1 test case)

Test #47:

score: 0
Accepted
time: 92ms
memory: 4032kb

input:

1
1000
491244 652071 1666725 2245508 2309623 3674278 3815190 3895176 4956515 5522405 7537365 8362107 8444302 8616346 8968438 10327819 10419925 10555358 10989561 11259157 12406771 15114514 15583101 15748986 16089431 16314547 16740769 18612633 19772171 22601657 23180475 24414392 24740704 24768505 2553...

output:

10000
1 435004052 224151799 442170885 627065985 822377578 847263977 104745957 940544230 841948309 431891279 680254671 620151317 22623533 526299306 579149963 426735186 423398288 875407394 829219766 104487392 87767109 714553280 964787003 191923287 423174254 283894275 204669150 59759694 466326592 35174...

result:

ok OK (1 test case)

Test #48:

score: 0
Accepted
time: 101ms
memory: 3980kb

input:

1
1000
410716 1339786 2155946 2774561 3624086 3972426 4119112 4679152 4944340 6889207 7070836 7355624 7656760 8593994 9739580 11432916 11607158 12460737 12832336 13038918 14177276 14522871 15419287 15464353 17027524 17957534 18709000 19743076 20812754 23499539 23759623 26131682 26765427 26830903 281...

output:

9996
1 978890088 136123476 67413061 226145309 372997300 383039486 262061590 618829877 276414151 984491131 279878004 85405812 574787072 150113248 931310164 426206356 186024666 61469549 570415513 65495384 477886054 47578849 595524125 337569870 705240645 891406721 579642104 637296845 704133345 71776989...

result:

ok OK (1 test case)

Test #49:

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

input:

1
1000
237762 543844 2089941 2319338 4967911 5029817 6412997 7871781 8013512 8127029 8183272 8722653 8782294 9493111 11153463 13078177 13578078 13719354 13768511 15101991 15129690 15543372 17808784 18377048 19595196 19708014 20358715 22006340 22914605 24553195 25489801 25586431 25874483 26111708 278...

output:

9998
1 911444238 280095360 150089108 321354134 653060440 546434802 288664439 712564274 338572750 363390773 171034776 733504433 434663595 465124138 809120205 713072955 885143474 689687901 605920640 482498906 627474072 777592975 398374922 14601231 327473214 844108623 541755767 127859490 44972794 60801...

result:

ok OK (1 test case)

Test #50:

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

input:

100
8
2159 1987 7869 634 1171 2406 9110 2501
0 2 1 2 1 3 1 1
6
7831 2289 8471 9887 1635 873
1 2 1 2 1 1
10
5667 9085 4539 122 708 4743 6535 7751 3975 2680
5 5 3 7 3 2 7 4 3 4
2
477 6541
0 0
6
9798 8860 5213 2193 1883 71
1 0 1 0 2 0
5
2432 4723 4433 8896 1811
3 9 3 5 3
9
4698 7750 6545 2727 5942 6454...

output:

10000
1 389325099 26596810 984932355 242982433 29418488 643887182 128778201 603994350 32920507 228016029 898229019 367827138 384175142 203959154 822775131 748476357 352677031 204299267 724172452 13951891 271659880 419625428 283848529 653485333 241727617 879307430 295706138 50533992 374289057 9276435...

result:

ok OK (100 test cases)

Test #51:

score: 0
Accepted
time: 74ms
memory: 4160kb

input:

1
1000
298699983 71839533 272804887 609675203 473225026 749854536 973389054 141662192 807676138 454286073 484030182 690348440 914886325 436720094 202418140 6269318 634190505 4061686 661049839 773575720 944825500 196653484 693782879 370586846 912838735 39236005 986787256 373349111 926867298 647215880...

output:

10000
1 918057570 181696403 336278831 281860119 99878433 599620465 457551976 143153034 846737275 564339531 698683984 270328587 112268121 108436865 294375819 989523221 95758694 707574555 603162103 158571679 798387343 501522835 494917679 401730452 864006158 627557927 690510957 203743159 453828467 5583...

result:

ok OK (1 test case)

Test #52:

score: 0
Accepted
time: 78ms
memory: 4096kb

input:

1
1000
471582494 608857167 198701022 543329239 977654864 393785803 278900201 341127137 422575329 441762188 385105059 609122432 392085879 717280955 312664738 125258226 693308945 590269418 92253512 257959157 44593184 74407678 614403829 80623331 270127146 134400606 70652869 846819456 465530618 52816771...

output:

10000
1 380059283 784706330 434108032 162846880 694935614 420360497 705801875 684170061 27279422 815993502 405138255 688545599 157691195 795125103 46295184 739412710 784869932 654875234 784833885 187690165 163470114 6805016 937170103 474626599 263088009 861723056 936017497 975146147 38891187 8623342...

result:

ok OK (1 test case)

Test #53:

score: 0
Accepted
time: 78ms
memory: 4044kb

input:

1
1000
837868675 78241049 139392295 101199738 484122022 129266839 458044226 333546872 341663438 630305353 514582877 153995378 256844528 788797657 365610842 278513693 338523391 500189646 864380373 966447995 810322030 101022521 306599757 97084284 128433746 578003432 336198001 347205697 99861046 337950...

output:

10000
1 556712901 764445173 104566793 66513079 726398461 439170223 503042981 392202155 28752446 604721266 558527936 652355122 470155729 472902315 166634901 990905175 885344979 375492357 874236895 504944922 375851056 895333838 82357964 989205109 7414393 56677019 882688307 666907208 394402505 29641630...

result:

ok OK (1 test case)

Test #54:

score: 0
Accepted
time: 74ms
memory: 4136kb

input:

1
1000
258876415 869270173 704514530 8747694 71789902 150046010 667635493 186612422 165416523 538762027 6104816 390661337 144291364 82224124 126462569 942231732 610948328 230733219 952933692 915903969 142523897 33429350 120081344 340060422 188581599 56783030 935131862 78651223 505110530 61854634 969...

output:

10000
1 87457299 13179111 361007244 706891346 832070172 114358454 23810802 5958608 44715186 992519868 281335133 268135794 646740405 545280789 992029729 465052556 265116434 342994433 942161826 96270777 465807378 245478038 838389378 200601990 531871104 215969328 759387424 369220692 122785109 589535472...

result:

ok OK (1 test case)

Test #55:

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

input:

1
1000
200100918 795800066 353940697 802483543 365760200 601504710 745757341 165461366 185934494 498277721 758067937 687237671 120948764 828476815 242727693 286582656 970297115 385573524 590439674 975651371 699804778 203029159 495370921 465573432 848130772 53284517 525405023 78262123 616067810 69418...

output:

10000
1 962785935 409472962 353278040 937059978 91806152 624637734 313697571 686354053 615982918 863380364 297359378 638316251 66341438 686975063 807645399 413798091 923894812 18277945 578887739 385838250 639381504 304055169 944221232 120370330 347748443 740919880 356363142 786357277 775982845 97364...

result:

ok OK (1 test case)

Test #56:

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

input:

1
1000
568882453 866921441 622062491 873863856 381158118 445346461 65029708 32273878 395642401 107646808 268435820 396957121 974255329 567249996 952164285 4581868 76247712 184186362 227058746 399439886 939971238 661362236 903057557 347419054 18700390 110973279 258229733 292862024 121080912 442166864...

output:

10000
1 752623400 84858442 315450283 585419575 184739637 762438981 302571168 604375920 838254594 94958258 27857361 719802267 810020622 252418304 873925323 60508356 873561201 717094517 753863781 835717507 985702695 822679460 959990831 334872977 125774183 306865577 493813673 710480709 846675066 701774...

result:

ok OK (1 test case)

Test #57:

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

input:

1
1000
709630619 233392114 233490524 328355525 231770597 121661469 406859230 519226153 125838969 802644071 646478508 312625167 611950221 367383798 634594937 872919035 99866512 266454799 203237109 125768812 792994899 27374851 621484344 713673656 619086073 256614361 885654145 791634297 278801461 12529...

output:

10000
1 730063254 378922281 93660892 329310921 906543023 830020518 253264005 648214313 145303772 460730376 820343830 433370039 147445879 274617920 633571577 914288242 517864292 857609103 663122539 488667001 325382136 357689546 214326506 655046155 56040687 416278659 506988719 279692143 947295411 2308...

result:

ok OK (1 test case)

Test #58:

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

input:

1
1000
13430074 68053963 142536141 823993368 307651118 750974308 122721917 27803195 212575401 998142291 362131204 276319375 555378218 850811309 643615222 591960993 607055329 843399650 196352391 745573336 815096089 495565101 2055273 515976415 657288143 758957759 631333443 534349985 582662343 12953621...

output:

10000
1 686281329 902613538 488946232 946907710 87422383 346420128 831622123 891332738 451225452 798135797 932797093 916401684 685836358 933026627 888195682 453130440 953463735 177819207 211920821 134568261 884395166 574154106 440810892 763432443 535002777 746868907 495523113 318741842 62538180 8282...

result:

ok OK (1 test case)

Test #59:

score: 0
Accepted
time: 74ms
memory: 3932kb

input:

1
1000
996315489 864408851 706867143 432147930 90577965 105142532 533411388 431240855 2587857 56100149 426658172 534467444 698501065 556317636 866705052 825625003 297678838 778146756 990328307 264573814 77868086 614255629 954719100 720205711 246039604 779345383 736534257 28739737 79905513 11381269 1...

output:

10000
1 238081177 271567273 547485699 907489866 861676867 27769270 924040104 585064662 34786139 260774646 634974561 220118790 701163711 231135715 974945524 213238286 283676141 319484029 213861894 127586831 540518453 123551165 337723658 54561297 717102184 948389814 464048837 788201282 378375149 92969...

result:

ok OK (1 test case)

Test #60:

score: 0
Accepted
time: 78ms
memory: 3976kb

input:

1
1000
457751014 213289071 251503444 536030823 791915559 763521736 293725605 643680040 697607289 99992512 812614859 131224112 296412824 677658837 970714147 902738262 86168872 505696725 228995700 6507825 336298379 58994046 225628057 826539394 117993455 202124485 674587943 963946152 605838714 1500169 ...

output:

10000
1 365263441 426785823 578727848 256109434 749781183 83409127 301665353 472891804 644567248 779837212 491328674 392213277 253942641 716088070 214616658 94371137 859261973 323819132 460226423 9565784 424559295 956803650 264854793 868464695 510170803 952825065 115751260 689689383 981438062 253753...

result:

ok OK (1 test case)

Test #61:

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

input:

10
100
3934643 4798522 7605978 11923203 14307332 15580656 32012253 38191910 43993984 45364716 78838742 83087817 90772142 91190649 99533851 99824878 103401232 112419020 113115656 113164985 115324483 137547613 138956855 145884258 168772739 189311060 191290717 195643045 225336739 226606897 273129924 27...

output:

0
1000000008
0
733864939
0
544334186
0
933844347
0
443664609
0
301874929
0
936255122
0
135899304
0
441196626
0
328295955

result:

ok OK (10 test cases)

Test #62:

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

input:

16
3
498228753 578689441 730510790
0 0 0
4
58521981 112072242 124592199 453635303
0 0 0 0
5
565603334 679983788 800479439 980949712 1000000008
0 0 0 0 0
6
6113693 302215705 365378713 391403530 746823222 909662466
0 0 0 0 0 0
7
256511619 280347562 282864204 728761951 873718619 938853095 1000000008
0 ...

output:

10000
1 921448517 833670718 520744068 673718570 62709154 881663347 672061161 60995709 193965459 638527242 818520341 637625852 911959178 753113688 835468692 857362639 821918024 785850783 374930332 281429499 133781491 716834126 582245098 798428565 987730785 555038945 63754463 879200376 28927739 618911...

result:

ok OK (16 test cases)

Test #63:

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

input:

1
1000
699372 1534202 3033857 3745540 7731895 8938225 10276776 12148555 12350970 16460229 16550984 16990743 17051566 18019424 18816669 19091679 21245438 21267586 22236212 23856554 24004664 25554538 25615989 25900024 26669622 26781777 28005497 29811563 29909664 30296728 30379425 30677835 30699321 315...

output:

10000
1 151186487 849734423 78042055 920760699 685109606 81729634 78265142 17554879 228758931 942250235 339789802 210602665 318700226 697143937 509128456 876976270 751659146 994470249 631146319 321073133 126207734 705070253 45617766 699564492 777031845 81100341 723135955 188751179 32215367 37942616 ...

result:

ok OK (1 test case)

Test #64:

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

input:

1
1000
333549936 428635227 921132541 558546162 227657291 459822517 173228834 971077420 34902350 641109994 352983378 655874888 895383433 971558780 548743161 26948189 964476685 394961115 776338457 150430831 359410359 841975403 971885844 587609505 290913367 843469988 42629684 81605355 52191087 30027368...

output:

10000
1 681504687 420728640 71914375 934282858 503783358 70746002 835866874 822787125 635923156 309976495 881600100 731729288 829454317 426139908 912643590 457414170 858165789 281879257 163930433 226798148 113185384 69663890 417934222 256918636 350349853 220293219 464284311 698688434 940472604 28453...

result:

ok OK (1 test case)

Test #65:

score: 0
Accepted
time: 74ms
memory: 4076kb

input:

1
1000
9691221 901694893 473398619 513101530 834260797 645135866 332294947 978473773 235778169 171178606 616758410 551338914 103813253 225455105 590513663 59848047 399015446 549502010 75192658 669056509 667060791 419011967 6465135 537706406 269732418 225819561 759226420 754828933 315214073 805779150...

output:

10000
1 73364487 442680439 584028968 517533859 284567125 317021600 82563140 706039327 723587576 61854607 761571916 203062023 612210977 766424865 107927073 938867490 80530842 873567922 100849536 833741688 179640830 554204425 378132550 211832450 639643033 981587346 219265662 580258319 970468955 501983...

result:

ok OK (1 test case)

Test #66:

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

input:

100
1
667927693
41124999
1
273769948
98729565
1
971429091
184257600
1
464910956
969056952
1
602415638
98111160
1
809713190
134839965
1
735141938
107115898
1
981522522
867849790
1
742145657
666795904
1
953689328
528325527
1
532129123
898827204
1
971100694
832763455
1
846142997
290376070
1
434247209
7...

output:

10000
1 863615164 5000 212165983 12497500 202786747 820834820 108455214 427889660 460561071 547344429 100505789 164233043 987650967 311401340 905890558 853359586 275703107 663446114 114910518 525952522 340347969 409369200 272363826 195243370 212562657 297993910 926920079 292543988 973105173 44162074...

result:

ok OK (100 test cases)

Test #67:

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

input:

1
1000
0 1758791 2343659 2846474 3434022 7652700 8253080 8682475 9405659 11944176 12562847 12673371 13522295 14858135 15330776 16160812 16635107 16991264 18005152 18032603 18731348 19153452 20937508 22107112 22323639 22588239 23702799 24419196 25155453 26551735 27271506 27468365 28904370 29126794 29...

output:

0
484938557

result:

ok OK (1 test case)

Test #68:

score: 0
Accepted
time: 57ms
memory: 3696kb

input:

1
1000
1524604 1646846 2338903 2740406 3942040 3989931 5024363 5109527 5196877 5872505 6582352 7777799 8173727 8685410 8915600 9182310 9321306 9464284 9525805 10827313 11808773 11893079 14391976 16125462 16473265 16944637 17943795 18017238 18500810 19091224 19179821 21457416 21539080 21745481 220104...

output:

0
149042459

result:

ok OK (1 test case)

Test #69:

score: 0
Accepted
time: 117ms
memory: 3756kb

input:

1
1000
773631 1271099 3953765 4084700 5041081 5335552 5576140 6747614 7027757 7344166 7714506 8831964 9790642 9941438 11025187 12106238 12472478 12712903 13529988 14291733 14739211 17428519 20544458 21885207 22200855 23721329 24137389 24680712 26042453 26970932 27063836 27430770 27857078 27978315 28...

output:

1
235190923 235190923

result:

ok OK (1 test case)

Test #70:

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

input:

1
1000
0 67424 2014750 5012509 6307284 6316493 6351222 7852345 8040778 8084229 10777085 10777154 10905187 11652681 11892364 12234217 13488004 13701500 13776090 14723966 15000536 15200318 15499307 16241329 17620285 19373854 19908820 20557656 21872465 24006771 24260068 24813456 24891673 25743075 26262...

output:

1
472526230 472526230

result:

ok OK (1 test case)

Test #71:

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

input:

1
1000
2295353 3461456 4344364 5915651 6918566 7393834 9334103 9838123 10830030 13736515 13825479 14606894 16070673 17301962 18487593 18547521 19267440 19932644 21525339 23557043 24224358 24625407 26153155 26665557 28173534 28305507 28493456 28720983 29903553 30478893 30859633 31193386 31656277 3391...

output:

2
789251375 295582233 789251375

result:

ok OK (1 test case)

Test #72:

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

input:

1
1000
2118267 2380145 2786828 2816505 6241267 6608195 7838712 8323036 10603372 10625540 10883561 12351514 12916606 13062847 13114051 14784771 15245928 15627189 16512688 16525086 16542632 16726071 17007610 17405216 17868667 18079562 18751319 23434852 23589375 24339074 26897701 27646883 31093138 3161...

output:

2
267542375 914240927 267542375

result:

ok OK (1 test case)

Test #73:

score: 0
Accepted
time: 135ms
memory: 3888kb

input:

1
1000
2708447 2966917 4035173 4113783 4616510 4792495 5218582 5771344 5952018 6723671 8132318 8164009 8353915 8824287 9240372 10058716 11049630 11298497 12239359 12441950 12610699 15604720 16083533 16925855 18316944 18633378 18643929 19334868 22075288 22657887 22674425 23109145 23539733 24928900 25...

output:

9999
1 937236132 611615112 553585737 90490931 247260304 431298396 744610896 655985463 855361656 962299109 143673053 541699508 547080007 826523551 463802816 989826575 525042802 454116830 343285837 298508262 287842061 363265650 555386265 404690838 746943603 846875542 23713357 383799990 657277728 19321...

result:

ok OK (1 test case)

Test #74:

score: 0
Accepted
time: 144ms
memory: 3872kb

input:

1
1000
318363 474352 1782864 2683720 2698336 3350190 3592733 4505908 4638998 4960629 5348676 6069010 6109152 7307430 8551335 9499873 9907789 10582983 12892501 13262454 14930949 15272706 15450931 15952341 17698343 18265425 18955758 20234474 20386851 21764708 22654329 22782293 24906330 24925987 250051...

output:

9999
1 559602513 33242300 731646657 124855790 778249176 340460339 358907685 760807519 87390302 522169743 108938235 75383651 397321856 959687945 22725877 639387636 714355225 216995743 34870454 73595626 794937128 277468317 294853973 258533194 878596127 689144987 87752037 965157882 941327174 775686296 ...

result:

ok OK (1 test case)

Test #75:

score: 0
Accepted
time: 84ms
memory: 3960kb

input:

1
1000
119122 1962488 2520113 3236722 3549078 5229478 6329478 6425296 6790067 7216677 7444198 7726912 7931422 8350259 8354679 9448546 10664660 11021700 11613345 12158834 12180397 12446155 12513227 12983874 14667838 14845483 14951787 15089592 18090127 18470591 19252921 19347773 20431573 20511208 2118...

output:

10000
1 172844077 937970470 850728478 296984020 253477304 913213954 871685109 903437913 389317104 489160710 781154599 279660956 245760158 47898132 209188782 10418361 565151647 629141662 188747002 474746105 833172391 232144187 779805423 217503139 785744788 352951255 549537868 381378052 27490782 69871...

result:

ok OK (1 test case)

Test #76:

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

input:

1
1000
24334 1888779 3702999 4295872 4749620 5339990 5428511 5484902 7114095 7274890 7781380 8037085 8151255 11084981 12716844 13843875 14580855 16385339 16845446 18032356 19126887 19968256 20794305 20892072 21597280 23555528 24844456 24945341 25206925 25667388 26581006 27063712 27217869 27904065 28...

output:

10000
1 475237945 432140205 359075950 120095118 571183623 574611994 944894827 700899515 600123747 848989287 541240187 670907229 133505353 898113729 576010150 894890486 41790630 181841824 39714210 118870067 659670080 700858659 204191619 126150978 296022054 267025441 767926530 183719714 884521386 1324...

result:

ok OK (1 test case)