bool operator<(const Num &a, const Num &b) {
    if (a.size() != b.size()) {
        return a.size() < b.size();
    } else {
        return a.repr < b.repr;
    }
}
const Num operator+(const Num &a, const Num &b) {
    string res;
    int len = max(a.size(), b.size());
    string x = a.repr;
    string y = b.repr;
    reverse(x.begin(), x.end());
    reverse(y.begin(), y.end());
    x += string(len-x.size(), '0');
    y += string(len-y.size(), '0');
    
    int c = 0;
    for (int i=0; i<len; ++i) {
        int d = val[x[i]] + val[y[i]] + c;
        res += dig[d%36];
        c = (d>=36);
    }
    if (c) {
        res += '1';
    }
    reverse(res.begin(), res.end());
    return Num(res);
}