#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "inline", "-ffast-math")
#pragma GCC target("abm,avx,mmx,popcnt,sse,sse2,sse3,ssse3,sse4")
inline long long read() {
  long long x(0), y(1);
  long long c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') y = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * y;
}
long long l, r, n, m, x, y, num;
int main() {
  n = read(), x = read();
  for (register int i = 1; i <= n; i++) {
    num = read();
    l = l * x + num;
  }
  m = read(), y = read();
  for (register int i = 1; i <= m; i++) {
    num = read();
    r = r * y + num;
  }
  puts(l == r ? "=" : (l > r ? ">" : "<"));
}
