#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define ALL(obj) begin(obj), end(obj)
#define cinv(a) rep(i,(int)a.size()) cin>>a[i]
#define pb push_back
#define eb emplace_back
typedef pair<int, int> Pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

template<typename T>
bool chmax(T& a, const T& b){if(a < b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a, const T& b){if(a > b){a=b;return true;}return false;}

int main() 
{
	int n; cin >> n;
	vl a(n), b(n); 
	rep(i, n) scanf("%lld", &a[i]);
	rep(i, n) scanf("%lld", &b[i]);

	reps(i, 1, n)
		a[i] = max(a[i-1], a[i]);

	ll ans;
	rep(i, n)
	{
		if (i == 0)
			ans = a[0] * b[0];
		else
			ans = max(ans, a[i] * b[i]);
		printf("%lld\n", ans);
	}
}

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,n) repi(i,0,n)
#define repi(i,a,n) for(ll i = a;i < (ll)n;++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SHOW(str,val) cout<<(str)<<" : "<<(val)<<endl;

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
// using P = pair<int, int>;
void YN(bool a) { cout << (a ? "Yes" : "No"); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void solve()
{
  ll n;
  cin >> n;
  ll thr = 3;
  ll cnt_3 = 0;
  for(thr; thr <= n; thr *= 3)
  {
    cnt_3++;
    ll cnt_5 = 0;
    for(ll fiv = 5; thr + fiv <= n; fiv *= 5)
    {
      cnt_5++;
      if (thr + fiv == n)
      {
        cout << cnt_3 << " " << cnt_5 << endl;
        return;
      }
    }
  }
  cout << -1;
}

int main()
{
  fastio;
  solve();

  return 0;
}