#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using lld = long double;
int main() {
  ll n, m;
  cin >> n >> m;
  int s[n];
  for (ll i = 0; i < n; i++) s[i] = 0;
  while (m--) {
    ll a, b;
    cin >> a >> b;
    if (a > n) {
      cout << "-1" << endl;
      break;
    }
    if (b < 0) {
      cout << "-1" << endl;
      break;
    }
    s[a - 1] = b;
  }
  if (s[0] == 0) {
    cout << "-1" << endl;
  } else {
    for (auto i : s) {
      cout << i;
    }
    cout << endl;
  }
}
