Sure, I can help you write a test case generator for the "Class Assignment" problem. The generator will create multiple datasets of students' scores and their corresponding classes based on the given classification rules. Here's how you can construct this test case generator in Python:

```python
import random

def generate_student_scores():
    pm = random.randint(0, 100)
    pe = random.randint(0, 100)
    pj = random.randint(0, 100)
    return pm, pe, pj

def tcgen():
    datasets = []
    num_datasets = random.randint(1, 1000)  # Number of datasets, up to 1000

    for _ in range(num_datasets):
        n = random.randint(1, 10000)  # Number of students, up to 10000
        dataset = []
        dataset.append(n)
        for _ in range(n):
            pm, pe, pj = generate_student_scores()
            dataset.append((pm, pe, pj))

        datasets.append(dataset)
    
    # Adding the end of input indicator
    datasets.append(0)
    
    return datasets

# Example usage to print a generated test case
if __name__ == "__main__":
    test_cases = tcgen()
    for dataset in test_cases:
        if dataset == 0:
            print(0)
        else:
            print(dataset[0])
            for scores in dataset[1:]:
                print(f"{scores[0]} {scores[1]} {scores[2]}")
```

### Explanation
1. **Function `generate_student_scores`**: This function generates random scores for math, English, and Japanese for a single student.
2. **Function `tcgen`**: This function generates multiple datasets.
   - It first determines the number of datasets (up to 1000).
   - For each dataset, it generates a random number of students (up to 10000).
   - For each student, it generates random scores using the `generate_student_scores` function and appends them to the current dataset.
   - Finally, it adds the end-of-input indicator (a single 0) after all datasets.
3. **Example usage**: This part demonstrates how to use the `tcgen` function to generate test cases and print them in the required format.

This generator ensures that the test cases cover a wide range of possible inputs, making it useful for thorough testing of the problem solution.