/*
================================
Author : Adnaan 'Zohran' Ahmed
Handle: adnaan1703
Heritage Institute of Technology
================================
*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF INT_MAX
#define X first
#define Y second
#define pb push_back
using namespace std;
typedef vector<int> vint;
typedef vector<long long int> vlint;
typedef vector<vector<int> > vvint;
typedef vector<vector<long long int> > vvlint;
typedef long long int lint;
void solve(void);
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
/*
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
*/
int t = 1;
// cin>>t;
while(t--)
solve();
return 0;
}
void solve(void) {
int n,m;
cin>>n>>m;
lint a = 0, b = 0;
while(n!=0) {
int tmp;
cin>>tmp;
a += (tmp * (pow(m,n-1)));
n--;
}
cin>>n>>m;
while(n!=0) {
int tmp;
cin>>tmp;
b += (tmp * (pow(m,n-1)));
n--;
}
if(a == b) {
cout<<'='<<endl;
}
else if(a>b)
cout<<'>'<<endl;
else
cout<<'<'<<endl;
}
LyoKICAgICAgICA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogICAgICAgIEF1dGhvciA6IEFkbmFhbiAnWm9ocmFuJyBBaG1lZAogICAgICAgIEhhbmRsZTogYWRuYWFuMTcwMwogICAgICAgIEhlcml0YWdlIEluc3RpdHV0ZSBvZiBUZWNobm9sb2d5CiAgICAgICAgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKi8KIAojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KIAojZGVmaW5lIE1PRCAxMDAwMDAwMDA3CiNkZWZpbmUgUEkgMy4xNDE1OTI2NTM1ODk3OTMyMzg0NjI2NDMzODMyNzk1CiNkZWZpbmUgSU5GIElOVF9NQVgKI2RlZmluZSBYIGZpcnN0CiNkZWZpbmUgWSBzZWNvbmQKI2RlZmluZSBwYiBwdXNoX2JhY2sKIAp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCnR5cGVkZWYgdmVjdG9yPGludD4gdmludDsKdHlwZWRlZiB2ZWN0b3I8bG9uZyBsb25nIGludD4gdmxpbnQ7CnR5cGVkZWYgdmVjdG9yPHZlY3RvcjxpbnQ+ID4gdnZpbnQ7CnR5cGVkZWYgdmVjdG9yPHZlY3Rvcjxsb25nIGxvbmcgaW50PiA+IHZ2bGludDsKdHlwZWRlZiBsb25nIGxvbmcgaW50IGxpbnQ7CiAKdm9pZCBzb2x2ZSh2b2lkKTsKIAppbnQgbWFpbih2b2lkKQp7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKE5VTEwpOwogCiAgICAvKgogICAgI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgICAgICBmcmVvcGVuKCJpbi50eHQiLCAiciIsIHN0ZGluKTsKICAgICNlbmRpZgogICAgKi8KIAogICAgaW50IHQgPSAxOwogICAgLy8gY2luPj50OwogICAgd2hpbGUodC0tKQogICAgICAgIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQoKdm9pZCBzb2x2ZSh2b2lkKSB7CiAgICBpbnQgbixtOwogICAgY2luPj5uPj5tOwoKICAgIGxpbnQgYSA9IDAsIGIgPSAwOwogICAgd2hpbGUobiE9MCkgewogICAgICAgIGludCB0bXA7CiAgICAgICAgY2luPj50bXA7CiAgICAgICAgYSArPSAodG1wICogKHBvdyhtLG4tMSkpKTsKICAgICAgICBuLS07CiAgICB9CgogICAgY2luPj5uPj5tOwogICAgd2hpbGUobiE9MCkgewogICAgICAgIGludCB0bXA7CiAgICAgICAgY2luPj50bXA7CiAgICAgICAgYiArPSAodG1wICogKHBvdyhtLG4tMSkpKTsKICAgICAgICBuLS07CiAgICB9CiAgICBpZihhID09IGIpIHsKICAgICAgICBjb3V0PDwnPSc8PGVuZGw7CiAgICB9CiAgICBlbHNlIGlmKGE+YikKICAgICAgICBjb3V0PDwnPic8PGVuZGw7CiAgICBlbHNlCiAgICAgICAgY291dDw8JzwnPDxlbmRsOwp9