# include <iostream>
using namespace std;

int main() {
    int n; scanf("%d", &n);
    string a = "";
    for (int i = 0; i < n; ++i) {
        char tmp[4] = ""; scanf("%s", tmp);
        a += tmp;
    }
    
    int m; scanf("%d", &m);
    string b = "";
    for (int i = 0; i < m; ++i) {
        char tmp[4] = ""; scanf("%s", tmp);
        b += tmp;
    }
    
    if (a < b) printf("%d\n", 1);
    else printf("%d\n", 0);
    
    return 0;
}
