#include <bits/stdc++.h>
using namespace std;
int n, b, tmp;
long long num(0), num1;
long long Get() {
  for (cin >> n >> b, num = 0; n--; cin >> tmp, num = num * b + tmp)
    ;
  return num;
}
int main() {
  char ans[] = {'=', '<', '>'};
  num1 = Get();
  num = Get();
  cout << ans[(num1 < num) + (num1 > num) * 2];
  return 0;
}
