//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  ll n,m,i,p,d,flg=0;cin>>n>>m;
  ll A[n];
  fo(i,0,n)A[i]=-1;
  
  if(m==0&&n==1){cout<<"0\n";return;}
  fo(i,0,m)
  {
    cin>>p>>d;
    if(A[p-1]==-1||A[p-1]==d)
    A[p-1]=d;
    else
    {flg=1;break;}
  }
  
  if(!flg)
  {
    if(n>1&&A[0]==0)flg=1;
    else
    {
       fo(i,0,n)
       {
          if(A[i]==-1)
          {
              if(i==0&&n>1)A[i]=1;
              else A[i]=0;
          }
       }
   }
   if(!flg)
   fo(i,0,n)cout<<A[i];
   cout<<"\n";
  }
  else
  cout<<"-1\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
