#include <bits/stdc++.h>
using namespace std;
long long int b10(int n, int arr[], int base) {
  long long int answer = 0;
  long long int multiplier = 1;
  for (int i = 1; i <= n; i++) {
    answer += (arr[n - i] * multiplier);
    multiplier *= base;
  }
  return answer;
}
long long int input() {
  long long int n, b;
  cin >> n >> b;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  return b10(n, arr, b);
}
int main() {
  long long int A = input();
  long long int B = input();
  if (A > B)
    cout << ">";
  else if (A < B)
    cout << "<";
  else
    cout << "=";
  return 0;
}
