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;
int power(int a, int b, int c, int ans = 1) {
  for (; b; b >>= 1, a = (long long)a * a % c)
    if (b & 1) ans = (long long)ans * a % c;
  return ans;
}
int is_prime(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
int b[(1 << 19)], c[(1 << 19)], d[(1 << 19)], da[(1 << 19)], dc[(1 << 19)],
    sa[(1 << 19)];
int mod, E, F;
int inv(int u) {
  return u < 2 ? u : (long long)mod / u * (mod - inv(mod % u)) % mod;
}
struct Cp {
  double x, y;
  Cp(double x = 0, double y = 0) : x(x), y(y) {}
  inline Cp operator+(const Cp &a) { return Cp(x + a.x, y + a.y); }
  inline Cp operator-(const Cp &a) { return Cp(x - a.x, y - a.y); }
  inline Cp operator*(const Cp &a) {
    return Cp(x * a.x - y * a.y, x * a.y + y * a.x);
  }
};
inline Cp conj(const Cp &a) { return Cp(a.x, -a.y); }
const int maxN = 1 << 18;
const double pi = acosl(-1);
int N = 1 << 16, LN = __builtin_ctz(N), L = 15, MASK = (1 << L) - 1;
int bitrev[maxN];
Cp w[maxN];
void FFTInit(int n) {
  N = n;
  LN = __builtin_ctz(N);
  for (int i = 0; i < N; ++i) {
    bitrev[i] = (bitrev[i >> 1] >> 1) | ((i & 1) << (LN - 1));
    w[i] = Cp(cos(2 * i * pi / N), sin(2 * i * pi / N));
  }
}
void FFT(Cp p[], int n) {
  int t1 = 18 - __builtin_ctz(n);
  for (int i = 0; i < n; ++i) {
    if (i < (bitrev[i] >> t1)) {
      swap(p[i], p[bitrev[i] >> t1]);
    }
  }
  for (int d = 0; (1 << d) < n; ++d) {
    int m = 1 << d, m2 = m * 2, rm = n >> (d + 1);
    for (int i = 0; i < n; i += m2) {
      for (int j = 0; j < m; ++j) {
        Cp &p1 = p[i + j + m], &p2 = p[i + j];
        Cp t = w[rm * j << t1] * p1;
        p1 = p2 - t;
        p2 = p2 + t;
      }
    }
  }
}
Cp A[maxN], B[maxN], C[maxN], D[maxN];
void mul(int a[maxN], int b[maxN], int k = N) {
  for (int i = 0; i < k; ++i) {
    A[i] = Cp(a[i] >> L, a[i] & MASK);
    B[i] = Cp(b[i] >> L, b[i] & MASK);
  }
  for (int i = k; i < N; ++i) {
    A[i] = B[i] = Cp(0, 0);
  }
  FFT(A, N);
  FFT(B, N);
  for (int i = 0; i < N; ++i) {
    int j = (N - i) % N;
    Cp da = (A[i] - conj(A[j])) * Cp(0, -0.5),
       db = (A[i] + conj(A[j])) * Cp(0.5, 0),
       dc = (B[i] - conj(B[j])) * Cp(0, -0.5),
       dd = (B[i] + conj(B[j])) * Cp(0.5, 0);
    C[j] = da * dd + da * dc * Cp(0, 1);
    D[j] = db * dd + db * dc * Cp(0, 1);
  }
  FFT(C, N);
  FFT(D, N);
  for (int i = 0; i < N; ++i) {
    long long da = (long long)(C[i].y / N + 0.5) % mod,
              db = (long long)(C[i].x / N + 0.5) % mod,
              dc = (long long)(D[i].y / N + 0.5) % mod,
              dd = (long long)(D[i].x / N + 0.5) % mod;
    a[i] = ((dd << (L * 2)) + ((db + dc) << L) + da) % mod;
  }
}
int ta[(1 << 19)], tc[(1 << 19)];
void conv(int *a, int n, int pw) {
  for (int i = 0; i < n; i++) {
    ta[i] = (long long)(a[i] % mod + mod) *
            power(pw, (long long)i * i % (mod - 1), mod) % mod;
    tc[i] = tc[(2 * n - i) % (2 * n)] =
        power(pw, mod - 1 - (long long)(n - i) * (n - i) % (mod - 1), mod);
  }
  tc[n] = 1;
  int N1 = 1;
  while (N1 < n * 2) N1 <<= 1;
  for (int i = n; i < N1; i++) ta[i] = 0;
  for (int i = n * 2; i < N1; i++) tc[i] = 0;
  mul(ta, tc, N1);
  for (int i = 0; i < n; i++)
    a[i] = (long long)power(pw, (long long)i * i % (mod - 1), mod) * ta[i + n] %
           mod;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", b + i);
  for (int i = 0; i < n; i++) scanf("%d", c + i);
  c[n] = c[0];
  for (int i = 0; i < n; i++) {
    if (c[i] - c[i + 1] & 1) return puts("0");
    dc[i] = c[i] - c[i + 1] >> 1;
  }
  mod = 2 * n + 1;
  while (mod < 1997321 || !is_prime(mod)) mod += 2 * n;
  E = 2;
  for (;; E++) {
    int ok = 1;
    for (int i = 2; i * i <= mod - 1 && ok; i++)
      if ((mod - 1) % i == 0) {
        if (power(E, i, mod) == 1) ok = 0;
        if (power(E, (mod - 1) / i, mod) == 1) ok = 0;
      }
    if (ok) break;
  }
  E = power(E, (mod - 1) / 2 / n, mod);
  for (int i = 0; i < n; i++) d[i] = b[(n - i) % n];
  FFTInit(1 << 18);
  conv(dc, n, E);
  conv(d, n, E);
  for (int i = 0; i < n; i++) da[i] = (long long)dc[i] * inv(d[i]) % mod;
  conv(da, n, inv(E));
  int t = inv(n);
  for (int i = 0; i < n; i++) {
    da[i] = (long long)da[i] * t % mod;
    if (da[i] > mod / 2) da[i] = da[i] - mod;
  }
  for (int i = 1; i < n; i++) {
    sa[i] = sa[i - 1] + da[i - 1];
    if (abs(sa[i]) > 5000) return puts("0");
  }
  long long c0 = -c[0], c1 = 0, c2 = n;
  for (int i = 0; i < n; i++) {
    long long t = b[i] - sa[i];
    c1 -= t << 1;
    c0 += t * t;
  }
  vector<int> ans;
  for (int i = -5000; i <= 5000; i++)
    if (c0 + c1 * i + c2 * i * i == 0) ans.push_back(i);
  cout << ans.size() << endl;
  for (int u : ans) {
    printf("%d", u);
    for (int i = 1; i < n; i++) printf(" %d", u + sa[i]);
    puts("");
  }
  return 0;
}