#include <bits/stdc++.h>
using namespace std;
long long int n, a, x[10], m, b, y[10], A, B;
int main() {
  cin >> n >> a;
  long int k = 1;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    A = A * a + x[i];
  }
  cin >> m >> b;
  long int j = 1;
  for (int i = 0; i < m; i++) {
    cin >> y[i];
    B = B * b + y[i];
  }
  if (A > B) {
    cout << ">";
  } else if (A < B) {
    cout << "<";
  } else {
    cout << "=";
  }
  return 0;
}
