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