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>
using namespace std;
inline int rd() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
  return x;
}
const int N = 600005;
int n, m, r[N];
long long g, mod, w[2][N], W[2][N], X[N], Y[N], a[N], b[N], c[N], da[N], rb[N],
    dc[N];
inline long long mul(long long a, long long b) {
  return (a * b - (long long)((long double)a * b / mod) * mod + mod) % mod;
}
inline long long pw(long long a, long long b) {
  long long r = 1;
  for (; b; b >>= 1, a = mul(a, a))
    if (b & 1) r = mul(r, a);
  return r;
}
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void gtP() {
  for (m = 1; m <= 2 * n; m <<= 1)
    ;
  long long lcm = 1ll * n * m / gcd(n, m);
  mod = 1;
  while (mod < 1e5) mod += lcm;
  while (true) {
    int ff = 1;
    for (int i = 2; 1ll * i * i <= mod; i++)
      if (mod % i == 0) {
        ff = 0;
        break;
      }
    if (ff)
      break;
    else
      mod += lcm;
  }
  for (g = 2;; g++) {
    int f = 1;
    for (int i = 2; 1ll * i * i <= mod; i++)
      if ((mod - 1) % i == 0)
        if (pw(g, i) == 1 || pw(g, (mod - 1) / i) == 1) {
          f = 0;
          break;
        }
    if (f) break;
  }
}
inline void gtW() {
  long long w0 = pw(g, (mod - 1) / m);
  w[0][0] = w[1][0] = 1;
  for (int i = 1; i < m; i++) w[1][m - i] = w[0][i] = mul(w[0][i - 1], w0);
  w0 = pw(g, (mod - 1) / n);
  W[0][0] = W[1][0] = 1;
  for (int i = 1; i < n; i++) W[1][n - i] = W[0][i] = mul(W[0][i - 1], w0);
}
inline void ntt(long long* a, int n, int f) {
  int l = 0;
  while ((1 << l) < n) l++;
  for (int i = 1; i < n; i++) r[i] = r[i >> 1] >> 1 | (i & 1) << (l - 1);
  for (int i = 0; i < n; i++)
    if (i < r[i]) swap(a[i], a[r[i]]);
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0, t = n / (i << 1); j < n; j += i << 1)
      for (int k = l = 0; k < i; k++, l += t) {
        long long x = a[j + k], y = mul(a[j + k + i], w[f][l]);
        a[j + k] = x + y;
        a[j + k + i] = x - y;
        if (a[j + k] >= mod) a[j + k] -= mod;
        if (a[j + k + i] < 0) a[j + k + i] += mod;
      }
  if (f) {
    long long iv = pw(n, mod - 2);
    for (int i = 0; i < n; i++) a[i] = mul(a[i], iv);
  }
}
inline void preB(int f) {
  for (int i = 0; i < 2 * n; i++)
    Y[2 * n - 1 - i] = W[f][1ll * i * (i - 1) / 2 % n];
  for (int i = 2 * n; i < m; i++) Y[i] = 0;
  ntt(Y, m, 0);
}
inline void bluestein(long long* a, int f) {
  for (int i = 0; i < n; i++)
    X[i] = mul(a[i], W[f][(n - 1ll * i * (i - 1) / 2 % n) % n]);
  for (int i = n; i < m; i++) X[i] = 0;
  ntt(X, m, 0);
  for (int i = 0; i < m; i++) X[i] = mul(X[i], Y[i]);
  ntt(X, m, 1);
  for (int i = 0; i < n; i++)
    a[i] = mul(X[2 * n - 1 - i], W[f][(n - 1ll * i * (i - 1) / 2 % n) % n]);
  if (f) {
    long long iv = pw(n, mod - 2);
    for (int i = 0; i < n; i++) a[i] = mul(a[i], iv);
  }
}
int main() {
  n = rd();
  for (int i = 0; i < n; i++) b[i] = rd();
  for (int i = 0; i < n; i++) c[i] = rd();
  gtP();
  gtW();
  long long iv2 = pw(mod - 2, mod - 2), ca = 0, cb = 0, cc = -c[0], sum = 0;
  for (int i = 0; i < n; i++) rb[i] = b[i];
  reverse(rb + 1, rb + n);
  for (int i = 0; i < n; i++)
    dc[i] = mul((c[(i + 1) % n] - c[i] + mod) % mod, iv2);
  preB(0);
  bluestein(rb, 0);
  bluestein(dc, 0);
  for (int i = 0; i < n; i++) da[i] = mul(dc[i], pw(rb[i], mod - 2));
  preB(1);
  bluestein(da, 1);
  for (int i = 0; i < n; i++) {
    long long v = (da[i] < mod - da[i]) ? da[i] : da[i] - mod;
    if (abs(v) > 5000000) {
      puts("0");
      return 0;
    } else
      a[i] = v;
  }
  for (int i = 0; i < n; i++) {
    ca++;
    cb += 2 * (sum - b[i]);
    cc += (sum - b[i]) * (sum - b[i]);
    sum += a[i];
  }
  if (sum != 0) {
    puts("0");
    return 0;
  }
  set<long long> ans;
  if (cb * cb - 4 * ca * cc >= 0) {
    long long s = (long long)(sqrt(cb * cb - 4 * ca * cc) + 0.5);
    if (s * s != cb * cb - 4 * ca * cc) {
      puts("0");
      return 0;
    }
    if ((-cb + s) % (2 * ca) == 0) ans.insert((-cb + s) / (2 * ca));
    if ((-cb - s) % (2 * ca) == 0) ans.insert((-cb - s) / (2 * ca));
  }
  printf("%d\n", (int)ans.size());
  for (set<long long>::iterator it = ans.begin(); it != ans.end(); it++) {
    long long x = *it;
    for (int i = 0; i < n; i++) printf("%lld ", x), x += a[i];
    puts("");
  }
}