Language: C++

#include <bits/stdc++.h>
using namespace std;
string to_string(int num) {
	string res;
	while(num) {
		res.push_back(num%10+'0');
		num/=10;
	}
		reverse(res.begin(),res.end());

	return res;
}
int to_int(string str) {
	int res=0;
	reverse(str.begin(),str.end());
	for(int i=0;i<str.size();i++) {
		res+=(str[i]-'0')*pow(10,i);
	}
	return res;
}

int main() {
	int n,m;
	cin>>n>>m;
	pair < int ,char > p[10];
	for(int i=0;i<m;i++) {
		cin>>p[i].first>>p[i].second;
	}
	for(int i=pow(10,n-1);i<pow(10,n);i++) {
		string s=to_string(i);
//		cout<<i<<'\n';
		bool ok=1;
		for(int j=0;j<m;j++) {
			if(s[p[j].first-1]!=p[j].second) ok=0; 
		}
		if(ok && s==to_string(to_int(s))) {
			cout<<s<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:35: error: call of overloaded 'to_string(int&)' is ambiguous
   30 |                 string s=to_string(i);
      |                          ~~~~~~~~~^~~
a.cc:3:8: note: candidate: 'std::string to_string(int)'
    3 | string to_string(int num) {
      |        ^~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4240:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
 4240 |   to_string(int __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4259:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
 4259 |   to_string(unsigned __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4275:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
 4275 |   to_string(long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4294:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
 4294 |   to_string(unsigned long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4310:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
 4310 |   to_string(long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4327:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
 4327 |   to_string(unsigned long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4401:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
 4401 |   to_string(float __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4411:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
 4411 |   to_string(double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4421:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
 4421 |   to_string(long double __val)
      |   ^~~~~~~~~
a.cc:36:38: error: call of overloaded 'to_string(int)' is ambiguous
   36 |                 if(ok && s==to_string(to_int(s))) {
      |                             ~~~~~~~~~^~~~~~~~~~~
a.cc:3:8: note: candidate: 'std::string to_string(int)'
    3 | string to_string(int num) {
      |        ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4240:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
 4240 |   to_string(int __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4259:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
 4259 |   to_string(unsigned __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4275:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
 4275 |   to_string(long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4294:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
 4294 |   to_string(unsigned long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4310:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
 4310 |   to_string(long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4327:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
 4327 |   to_string(unsigned long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4401:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
 4401 |   to_string(float __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4411:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
 4411 |   to_string(double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4421:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
 4421 |   to_string(long double __val)
      |   ^~~~~~~~~