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