// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;


signed main(){
  int n, m;
  cin >> n >> m;
  int s[n];
  for (int i = 0; i < n; i++){
    s[i] = 11;
  }

  bool could = true;
  int c[m], d[m];
  for (int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }
  for (int i = 0; i < m; i++){
    int a, b;
    a = c[i], b = d[i];
    a --;
    if (s[a] != 11 and s[a] != b){
      could = false;
      break;
    }
    s[a] = b;
  }
  
  if (s[0] == 0 and n != 1)
    could = false;
  
  for (int i = 0; i < n; i++)
    if (s[i] == 11){
      if (i == 0)
	s[i] = 1;
      else
	s[i] = 0;
  
  if (could){
    for (int i = 0; i < n; i++)
      cout << s[i];
    cout << endl;
  }else
    cout << -1 << endl;

  
}
