#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, l, m, n, x, y, bx, by, l1, l2, s1[15], s2[15];
  scanf("%lld %lld", &l1, &bx);
  for (i = 0; i < l1; i++) scanf("%lld", &s1[i]);
  scanf("%lld %lld", &l2, &by);
  for (i = 0; i < l2; i++) scanf("%lld", &s2[i]);
  for (i = 0, x = 0; i < l1; i++) {
    x = x * bx + s1[i];
  }
  for (i = 0, y = 0; i < l2; i++) {
    y = y * by + s2[i];
  }
  if (x < y)
    printf("<\n");
  else if (x == y)
    printf("=\n");
  else
    printf(">\n");
  return 0;
}
