def read_input(filename):
    """
    Read data from input file on form:
    eg.
    5 14 1 5 6 3 10
    where first number is N, second is K and rest is data set.
    args:
        filename :: string
            path to input file
    returns:
        out :: list of tuples.
    """
    out = []
    with open(filename, 'r') as f:
        for l in f:
            try:
                d = l.split()
                n = int(d[0])
                K = int(d[1])
                ts = [int(i) for i in d[2:]]
                if len(ts) != n:
                    raise TypeError('N not equal to length of T')
                out.append([n,K,ts])
            except IndexError:
                pass
    return out