I had to factory reset my Lenovo IdeaPad P500 for Windows 8?

Now, I do not know how to get Office back onto the computer. There's a free trial for 30 days but now I do not know what to do after that to have it permanently installed on my computer. Could someone please tell me what to do?

Once you open an OFFICE document, you will be asked to activate OFFICE. If you have not done so already you must purchase a Product Key for the copy of Office which you wish to use. Being W8 it is likely Office 365.

Download libre office or open office they are both free and as good as microsoft office they can open edit and save all microsoft office files

You have to buy it.

There's a free one called open office.org. It works the same