#include <bits/stdc++.h>
using namespace std;
const int MAX = 50;
long long dp[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  long long r = 0;
  dp[0] = 1;
  for (int i = 1; i < n; i++) dp[i] = dp[i - 1] * x;
  for (int i = n - 1; i >= 0; i--) {
    int tmp;
    cin >> tmp;
    r += tmp * dp[i];
  }
  int m, y;
  cin >> m >> y;
  long long l = 0;
  for (int i = 1; i < m; i++) dp[i] = dp[i - 1] * y;
  for (int i = m - 1; i >= 0; i--) {
    int tmp;
    cin >> tmp;
    l += tmp * dp[i];
  }
  if (r == l)
    cout << '=';
  else if (r > l)
    cout << '>';
  else
    cout << '<';
}
