#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int64_t> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int64_t maxA = 0;
    int64_t lastC = 0;
    for (int i = 0; i < n; i++) {
        int64_t b;
        cin >> b;

        maxA = max(a[i], maxA);
        lastC = max(b * maxA, lastC);

        cout << lastC << endl;
    }

    return 0;
}
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int T;
    cin>>T;
    for (int i=0; i<T; i++)
    {
        int N;
        cin>>N;
        string S[3];
        for (string &s: S)
        {
            cin>>s;
            s = s+s;
        }

        auto check = [&](string t)
        {
            for (int i=0; i<3; i++)
            {
                int p = 0;
                for (int j=0; j<4*N && p<2*N+1; j++)
                    if (S[i][j]==t[p])
                        p++;
                if (p<2*N+1)
                    return false;
            }
            return true;
        };

        bool ok = false;
        for (int j=0; j<2 && !ok; j++)
            for (int k=0; k<2 && !ok; k++)
                for (int l=0; l<2 && !ok; l++)
                    for (int k=0; k<3 && !ok; k++)
                    {
                        string s1 = string(N, j==0 ? '0' : '1');
                        string s2 = string(N, k==0 ? '0' : '1');
                        string s3 = string(1, l==0 ? '0' : '1');
                        string s;
                        if (k==0)
                            s = s3+s1+s2;
                        if (k==1)
                            s = s1+s3+s2;
                        if (k==2)
                            s = s1+s2+s3;
                        if (check(s))
                        {
                            cout<<s<<endl;
                            ok = true;
                        }
                    }
    }
}
