#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
const int N = 2e5;
long long X, Y, x[N], y[N];
long long nx, bx;
long long ny, by;
long long basx, basy;
int main() {
  cin >> nx >> bx;
  for (int i = 1; i <= nx; i++) cin >> x[i];
  cin >> ny >> by;
  for (int i = 1; i <= ny; i++) cin >> y[i];
  basx = basy = 1;
  for (int i = nx; i >= 1; i--) {
    X += basx * x[i];
    basx *= bx;
  }
  for (int i = ny; i >= 1; i--) {
    Y += basy * y[i];
    basy *= by;
  }
  if (X < Y)
    cout << '<';
  else if (X > Y)
    cout << '>';
  else
    cout << '=';
  return !1;
}
