#include <bits/stdc++.h>
using namespace std;
int main() {
  long long X;
  long long Y;
  int bx, by, nx, ny;
  cin >> nx >> bx;
  cin >> X;
  int temp;
  for (int i = 1; i < nx; i++) {
    cin >> temp;
    X = bx * X + temp;
  }
  cin >> ny >> by;
  cin >> Y;
  for (int i = 1; i < ny; i++) {
    cin >> temp;
    Y = by * Y + temp;
  }
  if (X < Y) {
    cout << "<" << endl;
  } else if (X > Y) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }
}
