#include<bits/stdc++.h>
#include <cmath>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
	cin.tie(NULL);
    long long n,m,k,l,j,p,i;
    cin>>n;
    for(i=1; powl(3,i)+5<=n; i++)
    {
        for(j=1; powl(5,j)+3<=n; j++)
        {
            k=powl(3,i);
            m=powl(5,j);
            p=m%10;
            //if(p==4)m++;
            if(k+m==n)
            {
                cout<<i<<" "<<j;
                return 0;
            }

        }
    }
    cout<<-1;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(long long i=k;i<=n;i++)
#define per(i,n,k) for(long long i=n;i>=k;i--)
#define pb push_back
#define fi first
#define se second
///#pragma GCC optimize(3,"Ofast","inline")
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<ll,ll> P;
ll gcd(ll a,ll b)
{
    ll r;
    while(b>0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
inline void write(ll x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}
inline ll read()
{
    ll x=0;
    char f=1,c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
            f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}

inline ll fp(ll a,ll b,ll mod)
{
    ll ans=1LL;
    while(b)
    {
        if(b&1LL)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1LL;
    }
    return ans;
}
inline ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}
ll a[1000005];
ll b[1000005];
int main()
{
    ll n=read();
    rep(i,1,n)a[i]=read();
    rep(i,1,n)b[i]=read();
    ll sum=0;
    rep(i,1,n)sum+=a[i]*b[i];
    if(sum==0)printf("Yes\n");
    else printf("No\n");
    return 0;
}
