#include <bits/stdc++.h>
using namespace std;
long long int p(long long int num, long long int e) {
  long long int res = 1;
  for (int i = 0; i < e; i++) res *= num;
  return res;
}
int main() {
  long long int x = 0, y = 0, n, m, bx, by, inp;
  cin >> n >> bx;
  while (n--) {
    cin >> inp;
    x += p(bx, n) * inp;
  }
  cin >> n >> by;
  while (n--) {
    cin >> inp;
    y += p(by, n) * inp;
  }
  if (x < y)
    cout << "<";
  else if (x == y)
    cout << "=";
  else
    cout << ">";
  return 0;
}
