#include <bits/stdc++.h>
using namespace std;
long long a[123], b[123];
int main() {
  long long a1, a2;
  long long b1, b2;
  long long c1 = 0, c2 = 0;
  scanf("%I64d%I64d", &a1, &a2);
  for (int i = 1; i <= a1; i++) {
    scanf("%I64d", &a[i]);
  }
  scanf("%I64d%I64d", &b1, &b2);
  for (int i = 1; i <= b1; i++) {
    scanf("%I64d", &b[i]);
  }
  long long c3 = 0, c4 = 0;
  for (int i = a1; i >= 1; i--) {
    long long tmp = c3;
    long long t2 = a[i];
    while (tmp) {
      t2 *= a2;
      tmp--;
    }
    c1 += t2;
    c3++;
  }
  for (int i = b1; i >= 1; i--) {
    long long tmp = c4;
    long long t2 = b[i];
    while (tmp) {
      t2 *= b2;
      tmp--;
    }
    c2 += t2;
    c4++;
  }
  if (c1 > c2) {
    printf(">\n");
  } else if (c1 < c2) {
    printf("<\n");
  } else {
    printf("=\n");
  }
  return 0;
}
