TeamViewer able to reconnect to Android device after factory reset?

Options

I'm not very familiar with technology - life is busy sometimes so please be kind...

My question is - how TeamViewer saves information of devices to connect to? Is it IMEI ? Serial number? IP? Or it leaves a file on the phone to be able to reconnect in the future?

I was tricked by fake Apple call center (i made the call) into installing quick support and someone created remote connection that kept reconnecting after the phone was dead and turned on again - I was not aware of that. I took sim out and disconnected phone from WIFI. After that i turned on Quick Support again and it produced pages and pages of log file within second trying to reconnect again... I did factory reset 3 times. I downloaded Quick Support again to double check and it is still trying to reconnect. I'm not able to do anything on it and all i have is a pop up window saying remote control...Is my device safe to use if i do factory reset again and never install anything by TeamViewer?

Thank you