#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX = 0x7fffffff;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = 100000 + 5;
const int maxm = 100000 + 5;
const int mod = 1e9 + 7;
int n, m;
int bn, bm;
long long dn, dm;
void indata() {
  cin >> n >> bn;
  dn = 0;
  long long t;
  for (int i = 1; i <= n; ++i) {
    cin >> t;
    dn = dn * bn + t;
  }
  cin >> m >> bm;
  dm = 0;
  for (int i = 1; i <= m; ++i) {
    cin >> t;
    dm = dm * bm + t;
  }
}
void slove() {
  if (dn < dm) {
    cout << "<" << endl;
  } else if (dn == dm) {
    cout << "=" << endl;
  } else {
    cout << ">" << endl;
  }
}
int main() {
  {
    indata();
    slove();
  }
  return 0;
}
