#include<bits/stdc++.h>usingnamespace std;typedeflonglong LL;constint N =100005;intmain(){//一定要LL 不然报错
LL n,m,bx,by;
LL X =0,Y =0;
cin>>n>>bx;for(int i = n -1;i >=0;i--){int x;
cin>>x;
X += x*pow(bx,i);}
cin>>m>>by;for(int i = m -1;i >=0;i--){int y;
cin>>y;
Y += y*pow(by,i);}if(X > Y)
cout<<'>'<<endl;elseif(X==Y)
cout<<'='<<endl;else
cout<<'<'<<endl;return0;}