#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  int n, m;
  long long x, y, t1, t2, z;
  scanf("%d", &n);
  scanf("%lld", &x);
  t1 = 0;
  for (int i = int(0); i <= int(n - 1); i++) {
    scanf("%lld", &z);
    t1 *= x;
    t1 += z;
  }
  scanf("%d", &m);
  scanf("%lld", &y);
  t2 = 0;
  for (int i = int(0); i <= int(m - 1); i++) {
    scanf("%lld", &z);
    t2 *= y;
    t2 += z;
  }
  if (t1 == t2)
    cout << "=";
  else if (t1 < t2)
    cout << "<";
  else
    cout << ">";
  return 0;
}
