#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int powe(int x, unsigned int y)
{
if( y == 0)
return 1;
else if (y%2 == 0)
return powe(x, y/2)*powe(x, y/2);
else
return x*powe(x, y/2)*powe(x, y/2);
}
int main(){
int bx,n1,by,n2;
int x[n1];
int yi[n2];
cin >> n1 >> bx;
for(int i = 0; i < n1; i++){
cin >> x[i];
}
int power = 0;
int sum = 0;
for(int s = n1 - 1; s >= 0 ;s--){
int r = powe(bx,power);
int l = x[s] * r;
sum = sum + l;
power++;
}
sum;
cin >> n2 >> by;
for(int i = 0; i < n2; i++){
cin >> yi[i];
}
int po = 0;
int sum1 = 0;
for(int s = n2 - 1; s >= 0; s--){
int t = powe(by,po);
int l = yi[s] * t;
sum1 = sum1 + l;
po++;
}
if(sum > sum1){
cout << ">" << endl;
}
if(sum < sum1){
cout << "<" << endl;
}
if(sum == sum1){
cout << "=" << endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgcG93ZShpbnQgeCwgdW5zaWduZWQgaW50IHkpCnsKICAgIGlmKCB5ID09IDApCiAgICAgICAgcmV0dXJuIDE7CiAgICBlbHNlIGlmICh5JTIgPT0gMCkKICAgICAgICByZXR1cm4gcG93ZSh4LCB5LzIpKnBvd2UoeCwgeS8yKTsKICAgIGVsc2UKICAgICAgICByZXR1cm4geCpwb3dlKHgsIHkvMikqcG93ZSh4LCB5LzIpOwogCn0KCmludCBtYWluKCl7CglpbnQgYngsbjEsYnksbjI7CgoJaW50IHhbbjFdOwoJaW50IHlpW24yXTsKCgljaW4gPj4gbjEgPj4gYng7Cglmb3IoaW50IGkgPSAwOyBpIDwgbjE7IGkrKyl7CgkJY2luID4+IHhbaV07Cgl9CgoJaW50IHBvd2VyID0gMDsKCWludCBzdW0gPSAwOwoJZm9yKGludCBzID0gbjEgLSAxOyBzID49I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