#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e+9 + 7;
const ll INF = LLONG_MAX;
const int N = (int)2e+5 + 8;
ll power(ll base, ll exp) {
  if (exp == 0) return 1;
  if (exp == 1) return base;
  ll t = power(base, exp / 2);
  t = (t * t);
  if (exp % 2 == 0)
    return t;
  else
    return ((base)*t);
}
void MAIN(ll tc) {
  int n, b;
  cin >> n >> b;
  ll x = 0;
  int k;
  for (int i = 0; i < n; i++) {
    cin >> k;
    x += k * power(b, (n - i - 1));
  }
  int m, c;
  cin >> m >> c;
  ll y = 0;
  for (int i = 0; i < m; i++) {
    cin >> k;
    y += k * power(c, (m - i - 1));
  }
  if (x == y)
    cout << "="
         << "\n";
  else if (x < y)
    cout << "<"
         << "\n";
  else
    cout << ">"
         << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout << setprecision(10);
  int test__cases = 1;
  for (int i = 1; i <= test__cases; i++) {
    MAIN(i);
  }
}
