def mark_doc(doc, wids, mark=None, pos=None):
    """
    Given a list of words and a set of word positions, mark the words in those positions.
    :param list doc: a list of words (strings)
    :param set wids: the positions of the words to be marked
    :param string mark: a string that sets the mark that will be applied
                        to each of the selected words
    :param string pos: can be one of {"prefix", "suffix"}
    :return: the marked list of words
    """
    if mark is None:
        mark = 'NEG'
    if pos is None:
        pos = 'suffix'
    marked_doc = []
    for i, tok in enumerate(doc):
        if i in wids:
            if pos == 'prefix':
                word = mark + '_' + tok
            else:
                word = tok + '_' + mark
            marked_doc.append(word)
        else:
            marked_doc.append(tok)
    return marked_doc
