def kmin(l1, l2, k):
    """
    Return the k smaller elements of two lists of tuples, sorted by their first
        element. If there are not enough elements, return all of them, sorted.
    Params:
        l1 (list of tuples): first list. Must be sorted.
        l2 (list of tuples): second list. Must be sorted.
        k (integer): number of elements to return.

    Return:
        (list): k smaller elements
    """
    results = []
    while len(results) < k:
        if l1 == []:
            if l2 == []:
                return results
            else:
                results.append(l2[0])
                l2 = l2[1:]
        else:
            if l2 == []:
                results.append(l1[0])
                l1 = l1[1:]
            else:
                if l1[0][0] > l2[0][0]:
                    results.append(l2[0])
                    l2 = l2[1:]
                else:
                    results.append(l1[0])
                    l1 = l1[1:]
    return results