#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long x = 0, y = 0;
  int n, m, bx, by;
  cin >> n >> bx;
  for (int i = 0; i < (int)(n); i++) {
    int a;
    cin >> a;
    x = x * bx + a;
  }
  cin >> m >> by;
  for (int i = 0; i < (int)(m); i++) {
    int a;
    cin >> a;
    y = y * by + a;
  }
  if (x == y)
    cout << '=';
  else if (x > y)
    cout << '>';
  else
    cout << '<';
  cout << endl;
  return 0;
}
