def extractDigit(i, n):
    """Extract the ith digit from n
       
       The rightmost digit is at position 0
       Digit positions are 76543210    
    """

    if i < 0:
        return -1
    
    return (n//pow(10, i))%10