#include <bits/stdc++.h>
using namespace std;
template <class T>
T inline myAbs(T n) {
  return (n < 0) ? -n : n;
}
template <class T>
T inline myPow(T base, T power) {
  T toRet = 1;
  while (power--) {
    toRet *= base;
  };
  return toRet;
}
int main() {
  long long n, b1, m, b2, x, y;
  while (cin >> n >> b1) {
    x = y = 0;
    long long d;
    while (n) {
      cin >> d;
      x += myPow(b1, --n) * d;
    }
    cin >> m >> b2;
    while (m) {
      cin >> d;
      y += myPow(b2, --m) * d;
    }
    if (x > y)
      cout << ">";
    else if (x < y)
      cout << "<";
    else
      cout << "=";
    cout << endl;
  }
  return 0;
}
