#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  bool flag = true;
  ll ans = 1;
  cin >> n >> m;
  vector<ll> num(n);
  for (ll i = 0; i < n; i++) num[i] = -1;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (s > n)
      flag = false;
    else if (num[s - 1] == -1 || num[s - 1] == c)
      num[s - 1] = c;
    else
      flag = false;
  }
  if (num[0] == 0) flag = false;
  if (!flag) {
    cout << -1 << endl;
    return 0;
  } else {
    if (num[0] == -1) num[0] = 1;
    for (ll i = 1; i < n; i++) {
      if (num[i] == -1) num[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << num[i];
  }
  cout << endl;
  return 0;
}
