#include <bits/stdc++.h>
using namespace std;
long long int x, y, n, sayi1, sayi, us = 1;
long long int pw(long long int a, long long int b) {
  long long int sayyi = 1;
  for (int i = 1; i <= b; i++) sayyi *= a;
  return sayyi;
}
int main() {
  scanf("%lld %lld", &x, &y);
  us = pw(y, x - 1);
  for (int i = 1; i <= x; i++) {
    scanf("%lld", &n);
    sayi += us * n;
    us /= y;
  }
  scanf("%lld %lld", &x, &y);
  us = pw(y, x - 1);
  for (int i = 1; i <= x; i++) {
    scanf("%lld", &n);
    sayi1 += us * n;
    us /= y;
  }
  if (sayi1 > sayi) printf("<");
  if (sayi > sayi1) printf(">");
  if (sayi1 == sayi) printf("=");
}
