    
An integer N (2 ≤ N ≤ 10,000), representing some quantity or size.
An integer M (1 ≤ M ≤ 1,000), representing another quantity or size.
M lines follow, each containing:
- An integer Si (1 ≤ Si ≤ 100).
- An integer ki (1 ≤ ki ≤ N).
- A list of ki integers, each between 1 and N.
The input ends with a line containing two zeros.

### Example Input:

```
3 2
5 2 1 3
8 2 2 3
0 0
```

### Function Signature:
Write a function f(inputs) that takes in the input. 
def f(inputs: List[Tuple[int, int, List[Tuple[int, int, List[int]]]]]): 
    ''' 
    inputs: a list of tuples, where each tuple contains:
        - an integer N
        - an integer M
        - a list of M tuples, where each tuple contains:
            - an integer Si
            - an integer ki
            - a list of ki integers 
    '''
    