def check1(base, xarr):
    ans = 0
    for i in range(n):
        ans += (xarr[i] * (base ** ((n - 1) - i)))
        if (ans > m):
            return False
    return True
def check1(base, xarr):
    ans = 0
    for i in range(n):
        ans += (xarr[i] * (base ** ((n - 1) - i)))
        if (ans > m):
            return False
    return True