An integer N (2 ≤ N ≤ 10,000), representing some quantity or size.
An integer M (1 ≤ M ≤ 1,000), representing some other quantity or size.
A list of M tuples, where each tuple contains an integer Si (1 ≤ Si ≤ 100), an integer ki (1 ≤ ki ≤ N), and a list of ki integers, where each integer is between 1 and N.

### Example Input:

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

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