#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    if (n == 1) {
      cout << 0 << endl;
      return 0;
    }
    cout << 1;
    rep(i, n - 1) cout << 0;
    cout << endl;
    return 0;
  }
  vector<pair<int, int>> p(m);
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    p[i] = make_pair(s, c);
  }
  sort(ALL(p));
  int f = p[0].first;
  int ans[n] = {};
  ans[0] = -1;
  ans[f - 1] = p[0].second;
  repi(i, 1, m) {
    if (f == p[i].first) {
      if (ans[f - 1] != p[i].second) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      f = p[i].first;
      ans[f - 1] = p[i].second;
    }
  }
  if (ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (ans[0] == -1) {
    cout << 1;
    rep(i, n - 1) cout << 0;
    cout << endl;
    return 0;
  }
  rep(i, n) cout << ans[i];
  cout << endl;
  return 0;
}