#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long base;
  cin >> base;
  long long a = 0;
  for (int i = 0; i < N; i++) {
    long long tmp;
    cin >> tmp;
    a = a * base + tmp;
  }
  long long b = 0;
  cin >> N >> base;
  for (int i = 0; i < N; i++) {
    long long tmp;
    cin >> tmp;
    b = b * base + tmp;
  }
  if (b == a) {
    cout << "=\n";
  } else if (b > a) {
    cout << "<\n";
  } else {
    cout << ">\n";
  }
  return 0;
}
