<think>
Okay, I need to implement the row_key and index_rows functions as per the given interface. Let's start with row_key. The function is supposed to return the first letter of a name in uppercase. So, for a given name string, I should take the first character, convert it to uppercase, and return that. But wait, what if the name is empty? The problem says that an empty list of names gives an empty index, but for row_key, the input is a single string. The task says that if the name is empty, maybe it's a valid input. But the problem statement doesn't mention handling names that are empty. However, the function is supposed to return the first letter. So, if the name is empty, perhaps it's an error? But the contract says to raise ValueError for invalid arguments. Wait, the user said that if the input is invalid, like a name that's empty, then row_key should raise a ValueError. Wait, the problem says that row_key returns the first letter of a name. So if the name is empty, then there's no first letter. So in that case, the function should raise a ValueError. But the problem says that the function should return the first letter. So, for example, if the name is an empty string, then row_key would raise an error. But the problem says that the function should handle that? Or is it allowed to have an empty name? The problem says that the function is supposed to return the first letter. So if the name is empty, then there's no first letter. Therefore, the function should raise a ValueError. But the problem says that the function should return the first letter. So, perhaps the function is supposed to handle names that are non-empty. But the problem says that the function is supposed to return the first letter. So, for example, if the name is "alice", then row_key returns "A". If the name is "Alice", it returns "A". But if the name is empty, then it's invalid. So, in the row_key function, I need to check that the name is not empty. So, the first step is to check if the name is empty. If it is, raise ValueError. Then, take the first character, uppercase it, and return.

So, the code for row_key would be:

def row_key(name: str) -> str:
    if not name:
        raise ValueError("Name cannot be empty")
    return name[0].upper()

But wait, what if the name is a string with a digit as the first character? Like "2nd". The problem says that the key is the first letter. But the problem says that if the name starts with a digit, what key to use? The problem says that the key is the first letter. But if the first character is a digit, then the first letter is the digit. But the problem says that the key is the first letter of the name. So, for example, if the name is "2nd", then the first character is '2', so the key is '2'. But the problem says that the key is the first letter. But the problem says that the key is the first letter of the name. So, the function is supposed to return the first character of the name, regardless of whether it's a letter or a digit. So, the function is correct as written. The problem says that the key is the first letter, but if the first character is a digit, then it's still the first character. So, the function is correct.

Now, the index_rows function. The function takes a list of names and returns a dictionary where each key is the row_key (first letter) and the value is a list of