def map_faiss_idx_to_file_and_line(idx, ID_dict):
    """
    return the File ID and line number given the faiss returned index
        the ID_dict format: key = file ID, value = (start line ID, number of lines in this file)
        the start line ID is the accumulated line number in previous files
    """
    keys = []
    for key in ID_dict:
        keys.append(key)
    keys = sorted(keys)
    for key in keys:
        start_line_ID = ID_dict[key][0]
        num_lines = ID_dict[key][1]
        if idx >= start_line_ID and idx < start_line_ID + num_lines:
            file_ID = key
            line_ID = idx - start_line_ID
            return (file_ID, line_ID)
    print("Did not find the mapping in the dictionary")
    raise ValueError