// NOTE: buggy — calls npow() which is never defined. Kept as-is for
// documentation purposes; useful as a "spot the bug" teaching example.
#include<bits/stdc++.h>
#include <unordered_set>

using namespace std;

int main() {
    int x; cin >> x;
    int base; cin >> base;
    int base10 = 0;

    for (int i=x-1; i >=0;i--){
        int n; cin >> n;
        base10 = base10 + npow(base,i);
    }

    int x1; cin >> x1;
    int second_base; cin >> second_base;
    int second_base10 = 0;

    for (int j=x1-1; j >=0;j--){
        int n; cin >> n;
        second_base10 = second_base10 + npow(second_base,j);
    }
    if(base10 > second_base10){
        cout << ">";
    }
else  if(base10 < second_base10){
        cout << "<";
    }
        else if(base10 == second_base10){
        cout << "=";
    }

}
