The input format is common in competitive programming: first a count, then that many items. Here, you read (number of words), then read words one per line. Use a loop: for i from 1 to n, read a word and process it.
In C++, you can use cin >> word for single words or getline(cin, word) for lines with spaces. This "read count, then loop" pattern appears in hundreds of problems. Learn it now and it becomes automatic.
You'll focus on the actual problem logic instead of input handling.