def unroll_rids(rids):
    """Recursively unroll rid id ranges into individual rids."""
    if not rids:
        return []

    m = rids[0]
    if m[1]:
        return ['R%d' % r for r in range(int(m[0]),
                                         int(m[1])+1)] + unroll_rids(rids[1:])
    return ['R%s' % m[0]] + unroll_rids(rids[1:])

    return []