Forgot passcode for your iPhone, iPad, or iPod touch, or your device is disabled - Apple Support
You need to restore it in recovery mode.
As for what carrier it's locked to, call Apple and give them the serial number.
Be prepared, there is a good chance it's activation locked, meaning that even after restoring it, you will be unable to activate it at all. There is a good chance it's stolen.
Why in the world would you purchase a carrier locked phone not knowing what carrier it's locked to, and one that's disabled as well?