Problem: <image>

Senor Vorpal Kickass'o invented an innovative method to encrypt integer sequences of length n. To encrypt a sequence, one has to choose a secret sequence <image>, that acts as a key.

Vorpal is very selective, so the key should be such a sequence bi, that its cyclic shifts are linearly independent, that is, there is no non-zero set of coefficients x0, x1, ..., xn - 1, such that <image> for all k at the same time.

After that for a sequence <image> you should build the following cipher:

<image>

In other words, you are to compute the quadratic deviation between each cyclic shift of bi and the sequence ai. The resulting sequence is the Kickass's cipher. The cipher is in development right now and Vorpal wants to decipher a sequence after it has been encrypted. You are to solve this problem for him. You are given sequences ci and bi. You are to find all suitable sequences ai.

Input

The first line contains a single integer n (<image>).

The second line contains n integers b0, b1, ..., bn - 1 (<image>).

The third line contains n integers c0, c1, ..., cn - 1 (<image>).

It is guaranteed that all cyclic shifts of sequence bi are linearly independent.

Output

In the first line print a single integer k — the number of sequences ai, such that after encrypting them with key bi you get the sequence ci.

After that in each of k next lines print n integers a0, a1, ..., an - 1. Print the sequences in lexicographical order.

Note that k could be equal to 0.

Examples

Input

1
1
0


Output

1
1


Input

1
100
81


Output

2
91
109


Input

3
1 1 3
165 185 197


Output

2
-6 -9 -1
8 5 13

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
const int N = 262144, Max = 5000;
int mod = 1, lim;
void up(int &x, int y) { x += y - mod, x += x >> 31 & mod; }
void down(int &x, int y) { x -= y, x += x >> 31 & mod; }
int pow(int x, int y, int mod = ::mod, int ans = 1) {
  for (; y; y >>= 1, x = (long long)x * x % mod)
    if (y & 1) ans = (long long)ans * x % mod;
  return ans;
}
namespace FFT {
const int m0 = 469762049, m1 = 998244353, m2 = 1004535809;
int s, rev[N];
void reduce(int &x, int mod) { x += x >> 31 & mod; }
struct Int {
  int a0, a1, a2;
  Int(int a = 0) { a0 = a1 = a2 = a; }
  Int(int a0, int a1, int a2) : a0(a0), a1(a1), a2(a2) {}
  inline friend void reduce(Int &x) {
    reduce(x.a0, m0), reduce(x.a1, m1), reduce(x.a2, m2);
  }
  void operator+=(const Int &rhs) {
    reduce(*this =
               Int(a0 += rhs.a0 - m0, a1 += rhs.a1 - m1, a2 += rhs.a2 - m2));
  }
  void operator-=(const Int &rhs) {
    reduce(*this = Int(a0 -= rhs.a0, a1 -= rhs.a1, a2 -= rhs.a2));
  }
  Int operator*(const Int &rhs) const {
    return Int((long long)a0 * rhs.a0 % m0, (long long)a1 * rhs.a1 % m1,
               (long long)a2 * rhs.a2 % m2);
  }
  Int operator~() const {
    return Int(pow(a0, m0 - 2, m0), pow(a1, m1 - 2, m1), pow(a2, m2 - 2, m2));
  }
  int number() const {
    const long long M = (long long)m0 * m1;
    long long x = ((long long)(a1 - a0 + m1) * 554580198 % m1 * m0 + a0) % M;
    long long y = (((long long)(a2 - x) % m2 + m2) * 395249030 % m2);
    return (y * (M % mod) + x) % mod;
  }
} a[N], b[N], wn[N], w[N];
void fftinit(int len) {
  wn[0] = lim = 1, s = -1;
  while (lim < len) lim <<= 1, ++s;
  for (int i = 0; i < lim; ++i) rev[i] = rev[i >> 1] >> 1 | (i & 1) << s;
  const Int g(pow(3, m0 / lim, m0), pow(3, m1 / lim, m1), pow(3, m2 / lim, m2));
  for (int i = 1; i < lim; ++i) wn[i] = wn[i - 1] * g;
}
void fft(Int *A, int typ) {
  for (int i = 0; i < lim; ++i)
    if (i < rev[i]) std::swap(A[i], A[rev[i]]);
  for (int i = 1; i < lim; i <<= 1) {
    for (int j = 0, t = lim / i / 2; j < i; ++j) w[j] = wn[j * t];
    for (int j = 0; j < lim; j += i << 1)
      for (int k = 0; k < i; ++k) {
        const Int x = A[k + j], y = A[k + j + i] * w[k];
        A[k + j] += y, (A[k + j + i] = x) -= y;
      }
  }
  if (!typ) {
    std::reverse(A + 1, A + lim);
    const Int il = ~Int(lim);
    for (int i = 0; i < lim; ++i) A[i] = A[i] * il;
  }
}
}  // namespace FFT
int n, b[N], c[N];
int A[N], B[N], C[N], D[N];
int pr[100], pt, root;
void factor(int n) {
  pt = 0;
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0) {
      pr[pt++] = i;
      do n /= i;
      while (n % i == 0);
    }
  if (n > 1) pr[pt++] = n;
}
void find_primitive_root() {
  for (int g = 2;; ++g) {
    bool ok = 1;
    for (int i = 0; i < pt; ++i)
      if (pow(g, mod / pr[i]) == 1) {
        ok = 0;
        break;
      }
    if (ok) return void(root = g);
  }
  assert(0);
}
int w[N];
FFT::Int a[N], _w[N];
void czt_init() {
  factor(mod - 1), find_primitive_root();
  const int g = pow(root, (mod - 1) / n);
  FFT::fftinit(n + n - 1);
  w[0] = 1;
  for (int i = 1; i <= n; ++i) w[i] = (long long)w[i - 1] * g % mod;
  for (int i = 0; i < n * 2 - 1; ++i) _w[i] = w[(long long)i * (i - 1) / 2 % n];
  for (int i = n * 2 - 1; i < lim; ++i) _w[i] = 0;
  std::reverse(_w, _w + n * 2 - 1), FFT::fft(_w, 1);
}
void czt(int *A, bool typ = 1) {
  for (int i = 0; i < n; ++i)
    a[i] = (long long)A[i] * w[n - (long long)i * (i - 1) / 2 % n] % mod;
  for (int i = n; i < lim; ++i) a[i] = 0;
  FFT::fft(a, 1);
  for (int i = 0; i < lim; ++i) a[i] = a[i] * _w[i];
  FFT::fft(a, 0), std::reverse(a, a + 2 * n - 1);
  for (int i = 0; i < n; ++i)
    A[i] =
        (long long)a[i].number() * w[n - (long long)i * (i - 1) / 2 % n] % mod;
  if (!typ) {
    const int il = pow(n, mod - 2);
    std::reverse(A + 1, A + n);
    for (int i = 0; i < n; ++i) A[i] = (long long)A[i] * il % mod;
  }
}
bool check_mod() {
  for (int i = 2; i * i <= mod; ++i)
    if (mod % i == 0) return 0;
  czt_init();
  for (int i = 0; i < n; ++i) B[i] = (mod - 2LL) * b[i] % mod;
  std::reverse(B + 1, B + n), czt(B);
  return !std::count(B, B + n, 0);
}
int seq[N];
bool make_seq(int x) {
  for (int i = 0; i < n; ++i) {
    up(x, A[i]), seq[i] = x;
    if (x > Max && x < mod - Max)
      return 0;
    else if (x > Max)
      seq[i] = seq[i] - mod;
  }
  return 1;
}
std::set<int> solve_equation(int p, int q, int r) {
  std::set<int> answer;
  for (int x = -Max; x <= Max; ++x) {
    int t = (x + mod) % mod;
    if (((long long)(p * t + q) % mod * t + r) % mod != 0) continue;
    if (!make_seq(t)) continue;
    answer.insert(x);
  }
  return answer;
}
std::set<int> answer[2];
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> b[i];
  for (int i = 0; i < n; ++i) std::cin >> c[i];
  mod = (5000000 / n) * n + 1;
  for (int time = 0; time < 1; ++time) {
    mod += n;
    while (!check_mod()) mod += n;
    for (int i = 0; i < n; ++i) C[i] = (c[i] - c[(i + n - 1) % n] + mod) % mod;
    czt(C);
    for (int i = 0; i < n; ++i) A[i] = pow(B[i], mod - 2, mod, C[i]);
    czt(A, 0), A[0] = D[0] = 0;
    for (int i = 1; i < n; ++i) up(D[i] = A[i], D[i - 1]);
    for (int i = 0; i < n; ++i) down(D[i], b[i]);
    int p = n, q = 0, r = mod - c[0];
    for (int i = 0; i < n; ++i) {
      q = (q + 2LL * D[i]) % mod;
      r = (r + (long long)D[i] * D[i]) % mod;
    }
    answer[time] = solve_equation(p, q, r);
  }
  std::set<int> ans = answer[0];
  std::cout << ans.size() << '\n';
  for (int p : ans) {
    make_seq((p + mod) % mod);
    for (int i = 0; i < n; ++i) std::cout << seq[i] << ' ';
    std::cout << '\n';
  }
  return 0;
}