#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x, y;
  while (cin >> x >> y) {
    long long a1 = 0;
    long long a2 = 0;
    for (int i = 1; i <= x; i++) {
      int t;
      cin >> t;
      a1 = a1 * y + t;
    }
    int c, d;
    cin >> c >> d;
    for (int i = 1; i <= c; i++) {
      int t;
      cin >> t;
      a2 = a2 * d + t;
    }
    if (a1 < a2)
      cout << "<" << endl;
    else if (a1 == a2)
      cout << "=" << endl;
    else
      cout << ">" << endl;
  }
}
