#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, a;
  cin >> n >> a;
  long long a1[n];
  for (int i = 0; i < n; i++) {
    cin >> a1[i];
  }
  long long m, b;
  cin >> m >> b;
  long long b1[m];
  for (int i = 0; i < m; i++) {
    cin >> b1[i];
  }
  reverse(a1, a1 + n);
  reverse(b1, b1 + m);
  long long p1 = 0, p2 = 0;
  for (int i = 0; i < n; i++) {
    p1 += a1[i] * pow(a, i);
  }
  for (int i = 0; i < m; i++) {
    p2 += b1[i] * pow(b, i);
  }
  if (p1 > p2)
    cout << ">" << endl;
  else if (p1 < p2)
    cout << "<" << endl;
  else
    cout << "=" << endl;
}
