#include <bits/stdc++.h>
int main() {
  double bx[10], by[10], n, i, x, y, mx, my;
  scanf("%lf%lf", &n, &x);
  n = n - 1;
  for (int i = 0; i <= n; i++) {
    scanf("%lf", &bx[i]);
  }
  mx = 0;
  my = 0;
  for (int i = 0; i <= n; i++) {
    mx = mx + bx[i] * pow(x, (n - ((float)i)));
  }
  scanf("%lf%lf", &n, &y);
  n = n - 1;
  for (int i = 0; i <= n; i++) {
    scanf("%lf", &by[i]);
  }
  for (int i = 0; i <= n; i++) {
    my = my + by[i] * pow(y, (n - ((float)i)));
  }
  if (my == mx) {
    printf("=");
  }
  if (my < mx) {
    printf(">");
  }
  if (my > mx) {
    printf("<");
  }
}
