Language: C++

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    int N,M;
    cin >> N >> M;
    int s[M],c[M];
    pair<int,int>p[M];
    map<int,int>mp;
    bool exist=true;
    string S[N],T,R;
    for(int i=0;i<M;++i){
        cin >> s[i] >> c[i];
        p[i]=make_pair(s[i],c[i]);
        S[s[i]-1]=toString(c[i]);
        ++mp[s[i]-1];
    }
    int tmp=0;
    int one_num=0;ten_num=0;hum_num=0;
    if(N==1){
        exist=true;
    for(int i=0;i<9;++i){
        one_num=i;
        tmp=i;
        for(int j=0;j<M;++j){
            if(tmp!=c[i]);
            exist=false;
        }
        if(exist){
            cout << i << endl;
            return 0;
        }
    }
    }
    else{
        if(N==2){
            for(int i=10;i<=99){
                tmp=i;
                one_num=tmp%10;
                tmp=tmp/10;
                ten_num=tmp%10;
                exist=true;
                for(int j=0;j<M;++j){
                    if(s[j]==1){
                        if(c[j]!=ten_num){
                            exist=false;
                        }
                    }
                    else{
                        if(c[j]!=one_num){
                            exist=false
                        }
                    }
                }
                cout << i << endl;
                return 0;
            }
        }
        else{
            if(N==3){
                for(int i=100;i<=999;++i){
                    tmp=i;
                one_num=tmp%10;
                tmp=tmp/10;
                ten_num=tmp%10;
                tmp=tmp/10;
                hum_num=tmp;
                for(int j=0;j<M;++j){
                    if(s[j]==1){
                        if(c[j]!=hum_num){
                            exist=false;
                        }
                    }
                    else{
                        if(s[j]==2){
                        if(c[j]!=ten_num){
                            exist=false
                        }
                        else{
                            if(c[j]!=one_num){
                                exist=false;
                            }
                        }
                        }
                    }
                }
                if(exist){
                cout << i << endl;
                return 0;
                }
            }   
                }
        }
    }
    cout << -1;
    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:19: error: 'ten_num' was not declared in this scope; did you mean 'one_num'?
   93 |     int one_num=0;ten_num=0;hum_num=0;
      |                   ^~~~~~~
      |                   one_num
a.cc:93:29: error: 'hum_num' was not declared in this scope
   93 |     int one_num=0;ten_num=0;hum_num=0;
      |                             ^~~~~~~
a.cc:111:31: error: expected ';' before ')' token
  111 |             for(int i=10;i<=99){
      |                               ^
      |                               ;
a.cc:125:40: error: expected ';' before '}' token
  125 |                             exist=false
      |                                        ^
      |                                        ;
  126 |                         }
      |                         ~               
a.cc:151:40: error: expected ';' before '}' token
  151 |                             exist=false
      |                                        ^
      |                                        ;
  152 |                         }
      |                         ~