#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, bx, x = 0, y = 0;
  cin >> n >> bx;
  while (n--) {
    int a;
    cin >> a;
    x = x * bx + a;
  }
  cin >> n >> bx;
  while (n--) {
    int a;
    cin >> a;
    y = y * bx + a;
  }
  if (x > y) cout << ">\n";
  if (x < y) cout << "<\n";
  if (x == y) cout << "=\n";
}
