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