def simplify(cigar):
    """To simplify a cigar by combining adjacent regions of the same type."""
    i = 0
    while i < len(cigar):
        if cigar[i][0] >= 0:
            break
        i += 1
    else:
        return []
    ret = []
    buf = cigar[i]
    for cig in cigar[i + 1:]:
        if cig[0] < 0:
            continue
        if buf[0] == cig[0]:
            buf = buf[0], buf[1] + cig[1]
        else:
            ret.append(buf)
            buf = cig
    ret.append(buf)
    return ret
