#include <bits/stdc++.h>
using namespace std;
long long power(long long X, int p) {
  long long re = 1;
  while (p) {
    if (p & 1) re *= X;
    X *= X;
    p >>= 1;
  }
  return re;
}
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  long long X = 0;
  for (int i = 0, a; i < n; i++) scanf("%d", &a), X += a * power(x, n - 1 - i);
  scanf("%d %d", &n, &x);
  long long Y = 0;
  for (int i = 0, a; i < n; i++) scanf("%d", &a), Y += power(x, n - i - 1) * a;
  if (X == Y)
    cout << "=";
  else if (X < Y)
    cout << "<";
  else
    cout << ">";
}
