Language: C++

#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> s;
  vector<int> c;
  if(m == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0;i < m;i++)
  {
    int S,C;
    cin >> S >> C;
    s.push_back(S);
    c.push_back(C);
  }
  // if(m == 1)
  // {
  //   if(c[0] == 0)
  //   {
  //     cout << -1 << endl;
  //     return 0;
  //   }
  // }
  int a = 10;
  bool a_f = false;
  int b = 10;
  bool b_f = false;
  int d = 10;
  bool d_f = false;
  bool flag = false;
  if(n == 1)
  {
    for(int i = 0;i < m;i++)
    {
      if(s[i] == 1 && d_f != true)
      {
        // cout << d << endl;
        d = min(d,c[i]);
        d_f = true;
        // if(d == 0)
        //   flag = true;
        // cout << d << endl;
      }
      else if(s[i] == 1 && d_f && d != c[i])
      {
        cout << -1 << endl;
        return 0;
      }
    }
    if(d == 10)
    {
      cout << -1 << endl;
      return 0;
    }
    cout << d << endl;
    return 0;
  }
  else if(n == 2)
  {
    for(int i = 0;i < m;i++)
    {
      if(s[i] == 1 && b_f != true)
      {
        b = min(b,c[i]);
        b_f = true;
      }
      else if(s[i] == 1 && b_f && b != c[i])
      {
        cout << -1 << endl;
        return 0;
      }
      else if(s[i] == 2 && d_f != true)
      {
        // cout << d << endl;
        d = min(d,c[i]);
        d_f = true;
        if(d == 0)
        flag = true;
        // cout << d << endl;
      }
      else if(s[i] == 2 && d_f && d != c[i])
      {
        cout << -1 << endl;
        return 0;
      }
    }
    if( b == 0 && d == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    if(b == 10 && d != 10)
    {
      cout << 1 << d  << endl;
      return 0;
    }
    if(b == 10)
      b = 0;
    if(d == 10)
      d = 0;
    if(b == 0 && d == 0)
    {
      // if(flag)
      // {
      //   cout << d << endl;
      //   return 0;
      // }
      cout << -1 << endl;
      return 0;
    }
    else if(b == 0 && d != 0)
    {
      cout << d << endl;
    }
    else
    {
      cout << b << d << endl;
    }
    return 0;
  }
  else if(n == 3)
  {
    for(int i = 0;i < m;i++)
    {
      // cout << i <<"?" << endl;
      if(s[i] == 1 && a_f != true)
      {
        a = min(a,c[i]);
        a_f = true;
      }
      else if(s[i] == 1 && a_f && a != c[i])
      {
        cout << -1 <<endl;
        return 0;
      }
      else if(s[i] == 2 && b_f != true)
      {
        b = min(b,c[i]);
        b_f = true;
      }
      else if(s[i] == 2 && b_f && b != c[i])
      {
        cout << -1 << endl;
        return 0;
      }
      else if(s[i] == 3 && d_f != true)
      {
        // cout << d << endl;
        d = min(d,c[i]);
        d_f = true;
        if(d == 0)
        flag = true;
        // cout << d << endl;
      }
      else if(s[i] == 3 && d_f && d != c[i])
      {
        cout << -1 << endl;
        return 0;
      }
    }
    if(a == 0 && b == 0 && d == 0)
    {
      cout << 0 << endl;
      return 0;
    }
    if(a == 10 && b != 10 && d != 10)
    {
      cout << 1 << b << d << endl;
      return 0;
    }
    if(a == 10 && b == 10 && d != 10)
      cout << 1 << 0 << d << endl;
      return 0;
    }
    if(a == 10)
      a = 0;
    if(b == 10)
      b = 0;
    if(d == 10)
      d = 0;
    if(a == 0 && b == 0 && d == 0)
    {
      // if(flag)
      // {
      //   cout << d << endl;
      //   return 0;
      // }
      cout << -1 << endl;
      return 0;
    }
    else if(a == 0 && b != 0 && d != 0)
    {
      cout << b << d << endl;
    }
    else if(a == 0 && b != 0 && d == 0)
    {
      cout << b << d << endl;
    }
    else if(a == 0 && b == 0 && d != 0)
    {
      cout << d << endl;
    }
    else
    {
      cout << a << b << d << endl;
    }
  }
  return 0;
}


Compiler output:
a.cc:229:3: error: expected unqualified-id before 'return'
  229 |   return 0;
      |   ^~~~~~
a.cc:230:1: error: expected declaration before '}' token
  230 | }
      | ^