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;
const long double PI = 2 * acosl(-1);
const int N = (1 << 18) + 5;
struct C {
  long double x, y;
  C() { x = y = 0; }
  C(long double x, long double y) : x(x), y(y) {}
  inline C operator-(const C& a) const { return C(x - a.x, y - a.y); }
  inline C operator+(const C& a) const { return C(x + a.x, y + a.y); }
  inline void operator+=(const C& a) {
    x += a.x;
    y += a.y;
  }
  inline C operator*(const long double& a) const { return C(x * a, y * a); }
  inline C operator/(const long double& a) const { return C(x / a, y / a); }
  inline C operator*(const C& a) const {
    return C(x * a.x - y * a.y, x * a.y + y * a.x);
  }
  inline C operator<<(const int& a) const {
    return C(ldexpl(x, a), ldexpl(y, a));
  }
  inline C operator>>(const int& a) const {
    return C(ldexpl(x, -a), ldexpl(y, -a));
  }
  inline long double norm2() const { return x * x + y * y; }
  inline long double norm() const { return sqrtl(norm2()); }
  inline C operator/(const C& a) const { return a.conj() / a.norm2() * *this; }
  inline C conj() const { return C(x, -y); }
} omg_[N];
int n_, lgn_;
int rev_[N];
void FFT_init(int n) {
  for (lgn_ = 0; 1 << lgn_ <= n; ++lgn_)
    ;
  n_ = 1 << lgn_;
  rev_[0] = 0;
  omg_[0] = C(1, 0);
  for (int i = 1; i < n_; i <<= 1)
    omg_[i] = C(cosl(i * PI / n_), sinl(i * PI / n_));
  for (int i = 1; i < n_; i++) {
    omg_[i] = omg_[i & (i - 1)] * omg_[i & -i];
    rev_[i] = rev_[i / 2] >> 1 | (i & 1) << (lgn_ - 1);
  }
}
void FFT(C* a, int flag = 0) {
  static C ww[N];
  for (int i = 0; i < n_; i++)
    if (rev_[i] < i) swap(a[i], a[rev_[i]]);
  for (int i = 0; i < lgn_; i++) {
    int t = 1 << i;
    for (int j = 0; j < t; ++j) ww[j] = omg_[j << (lgn_ - i - 1)];
    for (int j = 0; j < n_; j += t << 1) {
      C *at = a + j, *bt = a + j + t;
      for (int k = 0; k < t; ++k) {
        C s = bt[k] * ww[k];
        bt[k] = at[k] - s;
        at[k] += s;
      }
    }
  }
  if (flag) {
    reverse(a + 1, a + n_);
    for (int i = 0; i < n_; ++i) a[i] = a[i] >> lgn_;
  }
}
C F[N];
int pw[N], mod;
int ksm(long long a, int b, int c = 1) {
  for (; b; b /= 2, a = a * a % mod)
    if (b & 1) c = c * a % mod;
  return c;
}
inline int reduce(int x) { return x - ((mod / 2 - x) >> 31 & mod); }
int cnt, tests[N];
void dft_init(int n) {
  cnt = 0;
  for (int i = 2, j = n; i <= j; ++i)
    if (j % i == 0)
      for (tests[++cnt] = n / i; j % i == 0; j /= i)
        ;
  for (pw[1] = 1;; ++pw[1])
    if (ksm(pw[1], n) == 1) {
      int flag = 1;
      for (int j = 1; j <= cnt; ++j)
        if (ksm(pw[1], tests[j]) == 1) flag = 0;
      if (flag) break;
    }
  pw[0] = 1;
  for (int i = 1; i <= n; ++i) pw[i] = (long long)pw[i - 1] * pw[1] % mod;
  FFT_init(2 * n);
  for (int i = 0; i < n_; ++i) F[i] = C();
  for (int i = 0; i < 2 * n; ++i)
    F[i] = C(reduce(pw[(long long)i * (i - 1) / 2 % n]), 0);
  FFT(F);
}
void dft(int* a, int n, int flag = 0) {
  static C f[N];
  for (int i = 0; i < n_; ++i) f[i] = C();
  for (int i = 0; i < n; ++i)
    f[i] = C(
        reduce((long long)a[i] * pw[n - (long long)i * (i - 1) / 2 % n] % mod),
        0);
  reverse(f, f + n);
  FFT(f);
  for (int i = 0; i < n_; ++i) f[i] = f[i] * F[i];
  FFT(f, 1);
  for (int i = 0; i < n; ++i)
    a[i] = ((long long)floor(f[i + n - 1].x + 0.5) % mod) *
           pw[n - (long long)i * (i - 1) / 2 % n] % mod,
    a[i] += a[i] >> 31 & mod;
  if (flag) {
    reverse(a + 1, a + n);
    long long inv = mod - (mod - 1) / n;
    for (int i = 0; i < n; ++i) a[i] = a[i] * inv % mod;
  }
}
int n, a[N], b[N], c[N];
mt19937 rnd(123456);
vector<vector<int> > ans;
void chk() {
  for (int i = 0; i < 50; ++i) {
    int x = rnd() % n;
    long long sum = 0;
    for (int j = 0; j < n; ++j)
      sum +=
          (long long)(a[j] - c[(x + n - j) % n]) * (a[j] - c[(x + n - j) % n]);
    if (sum != b[x]) return;
  }
  ans.push_back(vector<int>(c, c + n));
}
void output() {
  sort(ans.begin(), ans.end());
  ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
  cout << ans.size() << '\n';
  for (auto i : ans) {
    for (auto j : i) cout << j << ' ';
    cout << '\n';
  }
  exit(0);
}
int get_sqrt(int x) {
  if (!x) return 0;
  if (ksm(x, mod / 2) != 1) return -1;
  for (;;) {
    int t = rnd() % mod, w = ((long long)t * t + mod - x) % mod,
        m = (mod + 1) / 2, a = 1, b = 0;
    for (int i = 30; i >= 0; --i) {
      int c = ((long long)a * a + (long long)b * b % mod * w) % mod,
          d = (long long)2 * a * b % mod;
      if (m >> i & 1)
        a = ((long long)t * c + (long long)d * w) % mod,
        b = (c + (long long)t * d) % mod;
      else
        a = c, b = d;
    }
    if (!b && (long long)a * a % mod == x) return a;
  }
}
void solve() {
  static int A[N], B[N], iA[N], sum, mul;
  for (int i = 2; i * i <= mod; ++i)
    if (mod % i == 0) return;
  dft_init(n);
  sum = 0;
  for (int i = 0; i < n; ++i)
    A[i] = a[i], sum = (sum + (long long)a[i] * a[i]) % mod;
  for (int i = 0; i < n; ++i)
    B[i] = (long long)(sum + mod - b[i]) * (mod + 1) / 2 % mod;
  dft(A, n);
  mul = 1;
  for (int i = 0; i < n; ++i) {
    if (!A[i]) return;
    iA[i] = mul;
    mul = (long long)mul * A[i] % mod;
  }
  A[n] = ksm(mul, mod - 2);
  for (int i = n - 1; i >= 0; --i)
    iA[i] = (long long)iA[i] * A[i + 1] % mod,
    A[i] = (long long)A[i] * A[i + 1] % mod;
  dft(B, n);
  for (int i = 0; i < n; ++i) B[i] = (long long)iA[i] * B[i] % mod;
  dft(B, n, 1);
  int t = (long long)iA[0] * (mod + 1) / 2 % mod,
      fa = (long long)n * t % mod * t % mod, fb = mod - 1, fc = 0;
  for (int i = 0; i < n; ++i)
    fb = (fb + (long long)2 * t * B[i]) % mod,
    fc = (fc + (long long)B[i] * B[i]) % mod;
  int delta = ((long long)fb * fb - (long long)4 * fa * fc) % mod;
  delta += delta >> 31 & mod;
  delta = get_sqrt(delta);
  if (delta == -1) output();
  int u = ksm(2 * fa % mod, mod - 2, (mod - fb + delta) % mod),
      v = ksm(2 * fa % mod, mod - 2, mod - (fb + delta) % mod);
  for (int i = 0; i < n; ++i) c[i] = reduce((B[i] + (long long)t * u) % mod);
  chk();
  for (int i = 0; i < n; ++i) c[i] = reduce((B[i] + (long long)t * v) % mod);
  chk();
  output();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[(n - i) % n];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (mod = (12000000 / n + 1) * n + 1;; mod += n) solve();
  return 0;
}