#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tt = 1;
  while (tt--) {
    long long n;
    cin >> n;
    long long arr[n];
    long long m;
    cin >> m;
    memset(arr, -1, sizeof arr);
    for (long long i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b;
      a -= 1;
      if (arr[a] != -1) {
        if (arr[a] != b) return cout << -1, 0;
      } else {
        arr[a] = b;
      }
    }
    for (long long i = 1; i < n; i++) {
      if (arr[i] == -1) arr[i] = 0;
    }
    if (arr[0] == -1) arr[0] = 1;
    if (arr[0] == 0 and n != 1) return cout << -1, 0;
    for (auto x : arr) cout << x;
  }
  return 0;
}
