#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() {
    cin.sync_with_stdio(0);
    cin.tie(0);
  }
} _;
long long powbx[11];
long long powby[11];
int main() {
  int n, bx;
  cin >> n >> bx;
  long long x = 0;
  powbx[0] = 1;
  for (int i = 1; i <= n; ++i) {
    powbx[i] = powbx[i - 1] * bx;
  }
  for (int i = 0, j = n - 1; i < n; ++i, --j) {
    long long t;
    cin >> t;
    x += t * powbx[j];
  }
  int m, by;
  cin >> m >> by;
  long long y = 0;
  powby[0] = 1;
  for (int i = 1; i <= m; ++i) {
    powby[i] = powby[i - 1] * by;
  }
  for (int i = 0, j = m - 1; i < m; ++i, --j) {
    long long t;
    cin >> t;
    y += t * powby[j];
  }
  if (x < y) {
    cout << "<" << endl;
  } else if (x > y) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}
