import itertools

def outcomes():
    """
    Compute the outcomes from rolling an eight-sided die twice.
    """
    return [[(i,j) for j in xrange(1,9)] for i in xrange(1,9)]

def favorable(outcome):
    """
    An outcome if favorable if the sum of both numbers in the
    outcome is even.
    """
    return sum(outcome)%2==0

a = outcomes()

# The size of the sample space
print 'Size of sample space:', len(a)*len(a[0])

# The sample space itself
for outcome in a:
    print outcome

b = itertools.chain(*a)
a = list(b)

# The number of favorable outcomes
b = [outcome for outcome in a if favorable(outcome)]
print 'Favorable outcomes:',len(b)