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