#include <bits/stdc++.h>
using namespace std;
int n, m, b1, b2;
long long a[15], b[15], s1, s2;
int main() {
  cin >> n >> b1;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m >> b2;
  for (int i = 0; i < m; i++) cin >> b[i];
  for (int i = 0; i < n; i++) s1 = s1 * b1 + a[i];
  for (int i = 0; i < m; i++) s2 = s2 * b2 + b[i];
  if (s1 > s2) {
    cout << ">";
  } else if (s1 < s2) {
    cout << "<";
  } else {
    cout << "=";
  }
  return 0;
}
