#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a = 0, b = 0, c, i, base, cur;
  int n;
  scanf("%d %I64d", &n, &base);
  cur = 1;
  for (i = 1; i < n; ++i) cur *= base;
  for (i = 0; i < n; ++i) {
    scanf("%I64d", &c);
    a += c * cur;
    cur /= base;
  }
  scanf("%d %I64d", &n, &base);
  cur = 1;
  for (i = 1; i < n; ++i) cur *= base;
  for (i = 0; i < n; ++i) {
    scanf("%I64d", &c);
    b += c * cur;
    cur /= base;
  }
  if (a < b)
    printf("<\n");
  else if (a == b)
    printf("=\n");
  else
    printf(">\n");
  return 0;
}
