#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, b, m, x = 0, y = 0;
  string s1, s2;
  cin >> n >> b;
  while (n--) {
    int a;
    cin >> a;
    x *= b;
    x += a;
  }
  cin >> n >> b;
  while (n--) {
    int a;
    cin >> a;
    y *= b;
    y += a;
  }
  if (x > y) {
    cout << ">" << endl;
    return 0;
  }
  if (x < y) {
    cout << "<" << endl;
    return 0;
  }
  if (x == y) {
    cout << "=" << endl;
    return 0;
  }
  return 0;
}
