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 std::reverse;
using std::swap;
int gcnt, r[262144], c2[200000], ic2[100000];
long long n, tn, len(1), mod, g, ig, inv, ninv;
long long vb[100000], vc[100000];
long long *w, tg[100], s[100000], pg[100000] = {1}, a[100000], b[100000],
                                  c[100000], t0[262144], t1[262144],
                                  wn[262144] = {1}, iwn[262144] = {1};
long long mul(long long& a, long long& b) {
  return (a * b - (long long)((long double)a * b / mod) * mod + mod) % mod;
}
long long qpow(long long x, long long p) {
  long long res(1);
  while (p) {
    if (p & 1) res = mul(res, x);
    x = mul(x, x);
    p >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  long long r;
  while (b) r = a % b, a = b, b = r;
  return a;
}
void get_mod() {
  tn = 2 * n - 1;
  while (len < tn) len <<= 1;
  long long lcm(n * len / gcd(n, len));
  mod = lcm + 1;
  while (mod <= 12000) mod += lcm;
  bool flag;
  while (1) {
    flag = 1;
    for (int i(2); 1ll * i * i <= mod; ++i) {
      if (mod % i == 0) {
        flag = 0;
        break;
      }
    }
    if (flag) return;
    mod += lcm;
  }
}
void get_g() {
  bool flag;
  long long tmp(mod - 1);
  for (int i(2); 1ll * i * i < mod; ++i) {
    if (tmp % i == 0) tg[gcnt++] = (mod - 1) / i;
    while (tmp % i == 0) tmp /= i;
  }
  if (tmp > 1) tg[gcnt++] = (mod - 1) / tmp;
  for (long long i(2);; ++i) {
    flag = 1;
    for (int j(0); j < gcnt; ++j) {
      if (qpow(i, tg[j]) == 1) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      g = i;
      return;
    }
  }
}
void ntt(long long* t, long long* ow = wn) {
  for (int i(0); i < len; ++i) {
    if (i < r[i]) swap(t[i], t[r[i]]);
  }
  for (int i(1), j(2), step(len >> 1); i < len; i <<= 1, j <<= 1, step >>= 1) {
    for (int k(0); k < len; k += j) {
      w = ow;
      for (int l(k); l < k + i; ++l, w += step) {
        long long tmp(mul(t[l + i], *w));
        t[l + i] = t[l] - tmp;
        if (t[l + i] < 0) t[l + i] += mod;
        t[l] += tmp;
        if (t[l] >= mod) t[l] -= mod;
      }
    }
  }
  if (ow == iwn) {
    for (int i(0); i < len; ++i) t[i] = mul(t[i], inv);
  }
}
void czt(long long* t) {
  for (int i(0); i < tn; ++i) t0[i] = pg[c2[i]];
  for (int i(0); i < n; ++i) t1[n - 1 - i] = mul(pg[ic2[i]], t[i]);
  ntt(t0);
  ntt(t1);
  for (int i(0); i < len; ++i) t1[i] = mul(t1[i], t0[i]);
  ntt(t1, iwn);
  for (int i(0); i < n; ++i) t[i] = mul(pg[ic2[i]], t1[n - 1 + i]);
  for (int i(tn); i < len; ++i) t0[i] = 0;
  for (int i(n); i < len; ++i) t1[i] = 0;
}
int main() {
  long long a0, c0, tmp, sum(0), psum(0);
  scanf("%lld", &n);
  get_mod();
  get_g();
  ig = qpow(g, mod - 2), inv = qpow(len, mod - 2), ninv = qpow(n, mod - 2);
  for (int i(0); i < len; ++i) r[i] = (r[i >> 1] | ((i & 1) ? len : 0)) >> 1;
  tmp = qpow(g, (mod - 1) / len);
  for (int i(1); i < len; ++i) wn[i] = mul(wn[i - 1], tmp);
  tmp = qpow(ig, (mod - 1) / len);
  for (int i(1); i < len; ++i) iwn[i] = mul(iwn[i - 1], tmp);
  tmp = qpow(g, (mod - 1) / n);
  for (int i(1); i < n; ++i) pg[i] = mul(pg[i - 1], tmp);
  for (int i(0); i < tn; ++i) c2[i + 1] = (c2[i] + i) % n;
  for (int i(0); i < n; ++i) ic2[i] = c2[i] ? n - c2[i] : c2[i];
  for (int i(0); i < n; ++i) scanf("%lld", b + i);
  scanf("%lld", &c0);
  c[0] = c0 % mod;
  for (int i(1); i < n; ++i) {
    scanf("%lld", &tmp);
    c[i] = tmp % mod;
  }
  for (int i(1); i < n; ++i) {
    tmp = c[i] - c[i - 1];
    vc[i] = tmp < 0 ? tmp + mod : tmp;
  }
  tmp = c[0] - c[n - 1];
  vc[0] = tmp < 0 ? tmp + mod : tmp;
  czt(vc);
  tmp = mod - 2;
  for (int i(1); i < n; ++i) vb[i] = mul(tmp, b[n - i]);
  vb[0] = mul(tmp, b[0]);
  czt(vb);
  for (int i(0); i < n; ++i) {
    tmp = qpow(vb[i], mod - 2);
    a[i] = mul(vc[i], tmp);
  }
  reverse(a + 1, a + n);
  czt(a);
  for (int i(0); i < n; ++i) a[i] = mul(a[i], ninv);
  for (int i(1); i < n; ++i) {
    tmp = a[i] > 6000 ? a[i] - mod : a[i];
    s[i] = s[i - 1] + tmp;
  }
  for (int i(0); i < n; ++i) {
    tmp = s[i] - b[i];
    sum += tmp, psum += tmp * tmp;
  }
  long long delta(sum * sum - n * (psum - c0));
  if (delta > 0) {
    long long sd((long long)(sqrt(delta) + 0.5));
    if (sd * sd != delta) {
      printf("0");
      return 0;
    }
    tmp = -sum - sd;
    if (tmp % n == 0) {
      a0 = tmp / n, tmp = -sum + sd;
      if (tmp % n == 0) {
        printf("2\n");
        for (int i(0); i < n; ++i) printf("%lld ", a0 + s[i]);
        printf("\n");
        a0 = tmp / n;
        for (int i(0); i < n; ++i) printf("%lld ", a0 + s[i]);
      } else {
        printf("1\n");
        for (int i(0); i < n; ++i) printf("%lld ", a0 + s[i]);
      }
    } else {
      tmp = -sum + sd;
      if (tmp % n == 0) {
        printf("1\n");
        a0 = tmp / n;
        for (int i(0); i < n; ++i) printf("%lld ", a0 + s[i]);
      } else
        printf("0");
    }
  } else if (delta == 0) {
    if (sum % n == 0) {
      printf("1\n");
      a0 = -sum / n;
      for (int i(0); i < n; ++i) printf("%lld ", a0 + s[i]);
    } else
      printf("0");
  } else
    printf("0");
  return 0;
}