#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n,m;
  cin >> n >> m;
  int arr[n+1];
  for(int i=0;i<=n;i++) arr[i] = -1;
  bool hit = true;
  for(int i=0;i<m;i++)
  {
    int x , c;
    cin >> x >> c;
    if(arr[x] == -1)
    {
      arr[x] = c;
    }
    else 
    {
      hit = false;
      break;
    }
    
  }
  if(hit)
  {
    if(arr[1] == -1) arr[i] = 1;
    for(int i=1;i<=n;i++)
    {
      if(arr[i] == -1) cout << 0;
      else cout << arr[i];
    }
    
  }
  else cout << -1;
  
}
  
