import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    string a = readln.chomp.split.join;
    int m = readln.chomp.to!int;
    string b = readln.chomp.split.join;
    writeln(a < b ? 1 : 0);
}
