#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n, i, m, f = 1;
  cin >> n >> m;
  int a[n];
  memset(a, -1, sizeof(a));
  for (i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (a[s - 1] == -1)
      a[s - 1] = c;
    else {
      if (a[s - 1] != c) {
        f = 0;
      }
    }
  }
  if (f == 0 || a[0] == 0)
    cout << -1;
  else {
    for (i = 0; i < n; i++) {
      if (a[i] != -1)
        cout << a[i];
      else {
        if (i == 0)
          cout << 1;
        else
          cout << 0;
      }
    }
  }
  return 0;
}
