#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, bx, num1 = 0;
  cin >> n >> bx;
  long long arr[n + 3];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (long long i = n - 1, j = 1; i >= 0; i--, j *= bx) {
    if (i == n - 1)
      num1 += arr[i];
    else
      num1 += arr[i] * j;
  }
  long long num2 = 0, m, by;
  cin >> m >> by;
  long long ar[m + 3];
  for (long long i = 0; i < m; i++) {
    cin >> ar[i];
  }
  for (long long i = m - 1, j = 1; i >= 0; i--, j *= by) {
    if (i == m - 1)
      num2 += ar[i];
    else
      num2 += ar[i] * j;
  }
  if (num1 > num2)
    cout << '>' << endl;
  else if (num1 < num2)
    cout << '<' << endl;
  else
    cout << '=' << endl;
  return 0;
}
