#include <bits/stdc++.h>
using namespace std;
long long ans[2];
int main() {
  for (int i = 0; i < 2; i++) {
    int n, b;
    cin >> n >> b;
    for (int j = 0; j < n; j++) {
      int t;
      cin >> t;
      ans[i] *= b, ans[i] += t;
    }
  }
  if (ans[0] < ans[1])
    cout << "<";
  else if (ans[0] == ans[1])
    cout << "=";
  else
    cout << ">";
  cout << "\n";
  return 0;
}
