#include <bits/stdc++.h>
using namespace std;
int nx, bx, ny, by;
int x, y;
long long ansx = 0, ansy = 0;
int main() {
  cin >> nx >> bx;
  for (int i = 0; i < nx; i++) cin >> x, ansx *= bx, ansx += x;
  cin >> ny >> by;
  for (int i = 0; i < ny; i++) cin >> y, ansy *= by, ansy += y;
  if (ansx == ansy) printf("=");
  if (ansx > ansy) printf(">");
  if (ansx < ansy) printf("<");
}
