import csv

def saveMatrix(A,filename):
    with open(filename, 'wb') as csvfile:
        writer = csv.writer(csvfile, dialect='excel')
        writer.writerow([''] + range(len(A[1])))
        for i in range(len(A[0])):
           writer.writerow([i] + [x for x in A[i,]])


def printMatrix(A):
        print ' ',
        for i in range(len(A[1])):
              print ' %s' % i,
        for i in range(len(A[0])):
            print
            print '%s ' % i,
            for j in range(len(A[1])):
                print '%d ' % A[i,j],
