<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

404. Fortune-telling with camomile
Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



Masha loves Petya. The following question gives her no rest: does Petya love her too? The best way to find this out is a fortune-telling. There are plenty ways of fortune predicting, but Masha prefers fortune-telling with camomile more than others. It's rules are simple. You should take camomile into the right hand and start picking petals one by one. After each petal you should pronounce one phrase from the predefined list. Such phrases like "loves", "doesn't love", "loves sincerely", "doubts", "wants to date", "laughs" are usually used. Phrases are pronounced from the first to the last. The list of phrases is cyclic, so after the last phrase you should pronounce the first one. The phrase that you pronounce after the last petal will be an answer.

Since Masha doesn't want to go to the forest and look for camomiles, she asks you to write the program which will simulate the process.

Input
First line of the input file contains two integer numbers N and M (1 ≤ N ≤ 100, 1 ≤ M ≤ 100), the number of petals and the number of phrases. Each of the following M lines contains one phrase. Phrases consist only of latin letters and their lengths are between 1 and 100.

Output
Output the resulting phrase.

Example(s)
sample input
sample output
6 4
loves
doesnt
sincerely
doubts
doesnt

sample input
sample output
9 3
loves
doesnt
hates
hates

<|response|>
1. Abridged Problem Statement  
You have N petals and a list of M phrases. Starting from the first phrase, you pluck each petal one by one and say the next phrase in the list, wrapping around cyclically. Determine which phrase is spoken at the N-th (last) petal.

2. Key Observations  
- The phrases repeat every M petals.  
- On petal k (1-based), the phrase index is (k−1) mod M.  
- We only need the phrase for k = N, so the answer index is (N−1) mod M.  

3. Full Solution Approach  
1. Read integers N (number of petals) and M (number of phrases).  
2. Read the M phrases into an array or list.  
3. Compute idx = (N − 1) % M.  
4. Output the phrase at position idx (zero-based) in the list.  

Time complexity is O(M) to read the input plus O(1) to compute the answer. Memory usage is O(M·L), where L is the maximum phrase length.

4. C++ Implementation with Detailed Comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    // Read N = number of petals, M = number of phrases
    cin >> N >> M;

    // Read the M phrases into a vector
    vector<string> phrases(M);
    for (int i = 0; i < M; i++) {
        cin >> phrases[i];
    }

    // Calculate zero-based index of the phrase for the N-th petal
    // Since we start at phrases[0] on petal 1,
    // the mapping is: petal k -> index (k-1) mod M
    int idx = (N - 1) % M;

    // Output the resulting phrase
    cout << phrases[idx] << "\n";

    return 0;
}
```

5. Python Implementation with Detailed Comments  
```python
import sys

def main():
    data = sys.stdin.read().split()
    # data[0]: N (number of petals)
    # data[1]: M (number of phrases)
    N = int(data[0])
    M = int(data[1])

    # data[2:] contains the M phrases
    phrases = data[2:]  # list of length M

    # Compute zero-based index for the N-th petal
    # Petal 1 -> phrases[0], ..., petal k -> phrases[(k-1) % M]
    idx = (N - 1) % M

    # Print the phrase spoken on the last petal
    print(phrases[idx])

if __name__ == "__main__":
    main()
```