#include <bits/stdc++.h>
using namespace std;
string str;
double EPS = 0.00001;
bool contains(vector<double> &v, double val) {
  for (int i = 0; i < v.size(); i++)
    if (abs(val - v[i]) < EPS) return true;
  return false;
}
int count(string &s, char c) {
  int res = 0;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == c) res++;
  return res;
}
struct point {
  int x, y;
};
int e;
bool align(point a1, point a2, point a3) {
  return (a2.x - a1.x) * (a3.y - a2.y) == (a3.x - a2.x) * (a2.y - a1.y);
}
int main() {
  int n, bx, m, by;
  cin >> n >> bx;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> m >> by;
  vector<int> y(m);
  for (int i = 0; i < m; i++) cin >> y[i];
  long long X = 0;
  for (int i = 0; i < n; i++) X += x[n - i - 1] * pow(bx, i);
  long long Y = 0;
  for (int i = 0; i < m; i++) Y += y[m - i - 1] * pow(by, i);
  if (X == Y)
    cout << '=';
  else if (X < Y)
    cout << '<';
  else
    cout << '>';
  cout << endl;
  return 0;
}
