This is the 2762nd most frequent Polish word.
flagi
"Flagi" in English means "flags."
The word 'flagi' is in the instrumental case, plural form, to indicate the means by which the action is performed (with flags).
Dzieci na wietrze machały flagami.
Children waved flags in the wind.
'Flagi' here is the nominative plural form and is the subject of the sentence, describing the main entities (three flags) performing the action of hanging.
Trzy flagi wisiały na masztach przed urzędem.
Three flags hung on the masts in front of the office.
'Flagi' in this sentence is in the genitive singular form, which is used to denote the absence or lack of an item (a flag).