In this case for all stress variants of the word we collect prefixes of length 1 through the length of the word, and similarly for suffixes, except that for the stress symbol we treat that together with the vowel it marks as a single symbol.
for the word gorod'a, all prefixes of the word would be g, go, gor, goro, gorod, gorod'a.