#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a;
  long long n;
  long long bx0;
  long long by0;
  long long bx;
  long long X;
  long long Y;
  long long by;
  long long i;
  bx = 1;
  by = 1;
  cin >> n >> bx0;
  Y = 0;
  X = 0;
  for (i = 1; i < n; i++) {
    bx = bx * bx0;
  }
  for (i = 1; i < n + 1; i++) {
    cin >> a;
    X = X + a * bx;
    bx = bx / bx0;
  }
  cin >> n >> by0;
  for (i = 1; i < n; i++) {
    by = by * by0;
  }
  for (i = 1; i < n + 1; i++) {
    cin >> a;
    Y = Y + a * by;
    by = by / by0;
  }
  if (X < Y) {
    cout << "<";
  }
  if (X == Y) {
    cout << "=";
  }
  if (X > Y) {
    cout << ">";
  }
}
