#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, bx;
  scanf("%d %d", &n, &bx);
  int n1 = n - 1;
  int i, x;
  long long int s = 0, k = 1;
  while (n1 > 0) {
    k *= bx;
    n1--;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    s += k * x;
    k /= bx;
  }
  scanf("%d %d", &n, &bx);
  n1 = n - 1;
  k = 1;
  long long int s1 = 0;
  while (n1 > 0) {
    k *= bx;
    n1--;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    s1 += k * x;
    if (s1 > s) break;
    k /= bx;
  }
  if (s1 > s) printf("<");
  if (s1 < s) printf(">");
  if (s1 == s) printf("=");
  return 0;
}
