#include <bits/stdc++.h>
int main() {
  int n, b1, m, b2;
  long long int x = 0, y = 0;
  scanf("%d%d", &n, &b1);
  for (int i = 0; i < n; i++) {
    int xx;
    scanf("%d", &xx);
    x = x * b1 + xx;
  }
  scanf("%d%d", &m, &b2);
  for (int i = 0; i < m; i++) {
    int xx;
    scanf("%d", &xx);
    y = y * b2 + xx;
  }
  if (x > y)
    printf(">\n");
  else if (x < y)
    printf("<\n");
  else
    printf("=\n");
}
