#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, bx, m, by;
  long long x = 0, y = 0;
  int temp;
  cin >> n >> bx;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    x *= bx;
    x += temp;
  }
  cin >> m >> by;
  for (int i = 0; i < m; i++) {
    cin >> temp;
    y *= by;
    y += temp;
  }
  if (x == y)
    cout << '=' << endl;
  else if (x < y)
    cout << '<' << endl;
  else
    cout << '>' << endl;
  return 0;
}
