from math import sqrt, ceil


def grid_shape(i, max_x=4):
    """Return a good grid shape, in x,y, for a number if items i"""

    x = round(sqrt(i))

    if x > max_x:
        x = max_x

    y = ceil(i / x)

    return x, y