#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d=0;
unsigned long long sum1=0,sum2=0;
cin>> a >> b;
for(int i=1;i<=a;i++){
cin >> c;
sum1+=(c *pow(b,a-i));
}
cin>> a >> b;
for(int i=1;i<=a;i++){
cin >> c;
sum2+=(c *pow(b,a-i));
}
if(sum1>sum2) cout <<">"<<endl;
if(sum1<sum2) cout <<"<"<<endl;
if(sum1==sum2) cout <<"="<<endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCl7CiAgICBpbnQgIGEsYixjLGQ9MDsKICAgIHVuc2lnbmVkIGxvbmcgbG9uZyBzdW0xPTAsc3VtMj0wOwogICAgY2luPj4gYSA+PiBiOwogICAgZm9yKGludCBpPTE7aTw9YTtpKyspewogICAgICAgIGNpbiA+PiBjOwogICAgICAgIHN1bTErPShjICpwb3coYixhLWkpKTsKICAgIH0KICAgIGNpbj4+IGEgPj4gYjsKICAgIGZvcihpbnQgaT0xO2k8PWE7aSsrKXsKICAgICAgICBjaW4gPj4gYzsKICAgICAgICBzdW0yKz0oYyAqcG93KGIsYS1pKSk7CiAgICB9CiAgICBpZihzdW0xPnN1bTIpIGNvdXQgPDwiPiI8PGVuZGw7CiAgICBpZihzdW0xPHN1bTIpIGNvdXQgPDwiPCI8PGVuZGw7CiAgICBpZihzdW0xPT1zdW0yKSBjb3V0IDw8Ij0iPDxlbmRsOwogICAgcmV0dXJuIDA7Cn0=