#include using namespace std; using ll = long long; const int mod = 258280327; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,fma") namespace { template void mult(const T *__restrict a, const T *__restrict b, T *__restrict res) { if (n <= 64) { // if length is small then naive multiplication if faster for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { res[i + j] = (res[i + j] + a[i] * b[j]) % mod; } } } else { // cout << n << endl; const int mid = n / 2; alignas(64) T btmp[n], E[n] = {}; auto atmp = btmp + mid; for (int i = 0; i < mid; i++) { atmp[i] = a[i] + a[i + mid]; // atmp(x) - sum of two halfs a(x) atmp[i] %= mod; btmp[i] = b[i] + b[i + mid]; // btmp(x) - sum of two halfs b(x) btmp[i] %= mod; } // cout << "sum" << endl; mult(atmp, btmp, E); // Calculate E(x) = (alow(x) + ahigh(x)) * (blow(x) + bhigh(x)) // cout << "mult1" << endl; mult(a + 0, b + 0, res); // Calculate rlow(x) = alow(x) * blow(x) // cout << "mult2" << endl; mult(a + mid, b + mid, res + n); // Calculate rhigh(x) = ahigh(x) * bhigh(x) // cout << "mult3" << endl; for (int i = 0; i < mid; i++) { // Then, calculate rmid(x) = E(x) - rlow(x) - rhigh(x) and write in memory const auto tmp = res[i + mid]; res[i + mid] += E[i] - res[i] - res[i + 2 * mid]; res[i + mid] %= mod; res[i + 2 * mid] += E[i + mid] - tmp - res[i + 3 * mid]; res[i + 2 * mid] %= mod; } // cout << "done" << endl; } } } const int nmax = (1 << 12) * 49; alignas(64) ll a[nmax],b[nmax],ret[2 * nmax]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,m; cin >> n; for(int i = 0;i <= n;++i) cin >> a[i]; cin >> m; for(int i = 0;i <= m;++i) cin >> b[i]; mult(a, b, ret); cout << n + m << endl; for(int i = 0;i <= n + m;++i){ auto x = ret[i]; if(ret[i] < 0) ret[i] += mod; cout << x << ' '; } cout << endl; return 0; }