#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, bx, m, by, q;
  double x = 0, y = 0;
  cin >> n >> bx;
  for (int i = n; i > 0; i--) {
    cin >> q;
    x += q * pow(bx, n - 1);
    n--;
  }
  cin >> m >> by;
  for (int i = m; i > 0; i--) {
    cin >> q;
    y += q * pow(by, m - 1);
    m--;
  }
  if (x < y) {
    printf("<\n");
  } else if (x > y) {
    printf(">\n");
  } else {
    printf("=\n");
  }
}
