#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long ss, pp, i, s, j, x, b;
  cin >> x >> b;
  ss = 0;
  for (i = 0; i < x; i++) {
    cin >> s;
    ss = ss * b + s;
  }
  cin >> x >> b;
  pp = 0;
  for (i = 0; i < x; i++) {
    cin >> s;
    pp = pp * b + s;
  }
  if (ss == pp)
    printf("=\n");
  else if (ss > pp)
    printf(">\n");
  else if (ss < pp)
    printf("<\n");
  return 0;
}
