#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, i, e, f, g, n, m, k, l, x, X, Y, A[11], B[11];
int main() {
  cin >> n >> x;
  for (i = 1; i <= n; i++) cin >> A[i];
  f = 1;
  for (i = n; i >= 1; i--) {
    X += f * A[i];
    f *= x;
  }
  cin >> n >> x;
  for (i = 1; i <= n; i++) cin >> B[i];
  f = 1;
  for (i = n; i >= 1; i--) {
    Y += f * B[i];
    f *= x;
  }
  if (X < Y)
    cout << "<";
  else if (X > Y)
    cout << ">";
  else
    cout << "=";
}
