def print_primes(primes, columns):
    """
    Print out primes aligned in a grid/columns.

    :param primes: list of primes
    :param columns: number of prime columns (-1: auto)
    """
    width = len('%d' % primes[-1]) + 1
    if columns == -1:
        columns = 80 // width
    prime_format = '%%%dd' % width
    text = ''
    column = 0
    for prime in primes:
        text += prime_format % prime
        column += 1
        if column % columns == 0:
            text += '\n'
    text += '\n'
    print(text)
